using System; using System.Linq; using System.Web.Mvc; using DSWeb.MvcShipping.DAL.MsCompanysDAL; using DSWeb.MvcShipping.Models.MsCompanys; using DSWeb.MvcShipping.Helper; using DSWeb.MvcShipping.Comm.Cookie; using HcUtility.Comm; using HcUtility.Core; using System.Collections.Generic; using DSWeb.MvcShipping.DAL.MsBaseInfoDAL; using DSWeb.EntityDA; using DSWeb.Models; using System.IO; namespace DSWeb.MvcShipping.Controllers { [JsonRequestBehavior] public class MsCompanysBXController : Controller { public ActionResult Index() { return View(); } public ActionResult Edit() { return View(); } public ContentResult GetData() { string comid = Convert.ToString(Session["COMPANYID"]); string condition = "comid = '"+comid+"'"; string strPath = "../../images/logo/noImage.gif"; string strPhotoPath = Server.MapPath(strPath); // CompanyBX head = null; head = MsCompanysBXDAL.GetData(strPath, strPhotoPath, condition); var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } [HttpPost] public ContentResult Save() { string comid = Convert.ToString(Session["COMPANYID"]); string data = Request["data"]; var head = JsonConvert.Deserialize(data); head.DbOperationType = DbOperationType.DbotIns; head.ComId = comid; var YingYeZhiZhao = Request.Files["YingYeZhiZhao"]; var PINTTAISHIYONGXIEYI = Request.Files["PINTTAISHIYONGXIEYI"]; var BAOXIANJINGJIWEITUOSHU = Request.Files["BAOXIANJINGJIWEITUOSHU"]; var BAOXIANJINGJIHEZUOXIEYI = Request.Files["BAOXIANJINGJIHEZUOXIEYI"]; if (YingYeZhiZhao != null&& YingYeZhiZhao.ContentLength!=0) { var path = Server.MapPath("../../UploadFilesBX1/" + head.GID); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } var size = YingYeZhiZhao.ContentLength; var name = Path.GetFileName(YingYeZhiZhao.FileName); var partname = DateTime.Now.ToString("yyyyMMddHHmmssfff") + name; string filename = path + "\\" + partname; if (System.IO.File.Exists(filename)) { System.IO.File.Delete(filename); } YingYeZhiZhao.SaveAs(filename); head.YingYeZhiZhao = filename; } if (PINTTAISHIYONGXIEYI != null && PINTTAISHIYONGXIEYI.ContentLength != 0) { var path = Server.MapPath("../../UploadFilesBX2/" + head.GID); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } var size = PINTTAISHIYONGXIEYI.ContentLength; var name = Path.GetFileName(PINTTAISHIYONGXIEYI.FileName); var partname = DateTime.Now.ToString("yyyyMMddHHmmssfff") + name; string filename = path + "\\" + partname; if (System.IO.File.Exists(filename)) { System.IO.File.Delete(filename); } PINTTAISHIYONGXIEYI.SaveAs(filename); head.PINTTAISHIYONGXIEYI = filename; } if (BAOXIANJINGJIWEITUOSHU != null && BAOXIANJINGJIWEITUOSHU.ContentLength != 0) { var path = Server.MapPath("../../UploadFilesBX3/" + head.GID); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } var size = BAOXIANJINGJIWEITUOSHU.ContentLength; var name = Path.GetFileName(BAOXIANJINGJIWEITUOSHU.FileName); var partname = DateTime.Now.ToString("yyyyMMddHHmmssfff") + name; string filename = path + "\\" + partname; if (System.IO.File.Exists(filename)) { System.IO.File.Delete(filename); } BAOXIANJINGJIWEITUOSHU.SaveAs(filename); head.BAOXIANJINGJIWEITUOSHU = filename; } if (BAOXIANJINGJIHEZUOXIEYI != null && BAOXIANJINGJIHEZUOXIEYI.ContentLength != 0) { var path = Server.MapPath("../../UploadFilesBX4/" + head.GID); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } var size = BAOXIANJINGJIHEZUOXIEYI.ContentLength; var name = Path.GetFileName(BAOXIANJINGJIHEZUOXIEYI.FileName); var partname = DateTime.Now.ToString("yyyyMMddHHmmssfff") + name; string filename = path + "\\" + partname; if (System.IO.File.Exists(filename)) { System.IO.File.Delete(filename); } BAOXIANJINGJIHEZUOXIEYI.SaveAs(filename); head.BAOXIANJINGJIHEZUOXIEYI = filename; } string msg = ""; DBResult result = MsCompanysBXDAL.Save(head); var json = JsonConvert.Serialize(new { success = result, Message = msg, Data = head.GID }); return new ContentResult() { Content = json }; } #region 删除 public ContentResult Delete(string data) { if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "") { var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) }; } // var head = JsonConvert.Deserialize(data); var modb = new ModelObjectDB(); //DBResult result = modb.Delete(head); DBResult result = MsCompanysDAL.Delete(head); if (result.Success == true) { DBResult result2 = MsCompanysDAL.setLog(head, Convert.ToString(Session["USERID"])); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #endregion } }