using System; using System.Linq; using System.Web.Mvc; using DSWeb.MvcShipping.DAL.MsOpOtherDAL; using DSWeb.MvcShipping.Models.MsOpOther; 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 DSWeb.Attributes; using DSWeb.MvcShipping.Models.MsSysBillNoSet; using DSWeb.MvcShipping.DAL.MsSysBillNoSet; using DSWeb.MvcShipping.Models.MsCodeServiceFeeTemplate; using System.IO; using System.Data; using System.Data.OleDb; using DSWeb.MvcShipping.DAL.MsInfoClient; using DSWeb.MvcShipping.DAL.MsSysParamSet; using System.Web.Configuration; using DSWeb.SoftMng.DAL.SoftSysTable; using DSWeb.Areas.SysMng.DAL.SysUser; using DSWeb.MvcShipping.DAL.MsCodeOpTemplate; using DSWeb.MvcShipping.DAL.ChMonthCloseDAL; using DSWeb.MvcShipping.DAL.MsChFeeDAL; using DSWeb.Areas.Dispatch.DB; using javax.xml.crypto; using System.Data.Entity.Migrations; using DSWeb.Areas.CommMng.DAL; using DSWeb.MvcShipping.Models.MsOp_SuperVision_Truck; using static com.sun.net.httpserver.Authenticator; using DSWeb.MvcShipping.Models.MsOpSeae; using DSWeb.MvcShipping.Helper.Repository; using DSWeb.MvcContainer.DAL.MsCodeCtnTk; namespace DSWeb.MvcShipping.Controllers { [JsonRequestBehavior] public class MsOp_SuperVision_TruckController : Controller { // // GET: /CommMng/Print/ public ActionResult Index() { return View(); } public ActionResult Edit() { return View(); } public ContentResult GetDataList(int start, int limit, string sort, string condition, string CODENAME = "") { var canlogin = BasicDataRefDAL.CheckLogin(Session); if (!canlogin.Success) { return (ContentResult)canlogin.Data; } var count = 0; //var userid = Convert.ToString(Session["USERID"]); //var uid = Session["USERID"].ToString(); //var corpid = Session["COMPANYID"].ToString(); var dataList = MsOp_SuperVision_TruckDAL.GetDataList(start, limit, sort, Convert.ToString(Session["USERID"]), condition, ref count); //var dataList = MsChDuiDAL.GetDataList(start, limit, condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), CookieConfig.GetCookie_OrgCode(Request), sort); //int count = MsChDuiDAL.getTotalCount(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), CookieConfig.GetCookie_OrgCode(Request)); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetData(string handle,string condition) { var canlogin = BasicDataRefDAL.CheckLogin(Session); if (!canlogin.Success) { return (ContentResult)canlogin.Data; } //var condition = " GID='" + GID + "' "; var result = MsOp_SuperVision_TruckDAL.GetData(condition, Session); if (result == null) { result = new OP_SuperVision_Truck_md(); //新建时默认值 result.BSNO = Guid.NewGuid().ToString(); result.CreatorID = Session["USERID"].ToString(); ; result.Creator = Session["SHOWNAME"].ToString(); result.OP = Session["SHOWNAME"].ToString(); result.SALE = Session["SHOWNAME"].ToString(); result.DEPTID = Session["DEPTGID"].ToString(); result.CORPID = Session["COMPANYID"].ToString(); result.SALECORPID = Session["COMPANYID"].ToString(); result.BILLTYPE = "主单"; result.TRANSPORTTYPE = "普通业务"; result.FEEFRT = "PP"; } var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = 1, data = result }); return new ContentResult() { Content = json }; } public ContentResult Save(string opstatus, string data, string data2, string body) { var canlogin = BasicDataRefDAL.CheckLogin(Session); if (!canlogin.Success) { return (ContentResult)canlogin.Data; } data = data.Replace("❥", "<"); var headData = JsonConvert.Deserialize(data.Replace("}", ",") + data2.Replace("{", ""));//(data.Replace("}", ",") + data2.Replace("{", "") var bodyList = JsonConvert.Deserialize>(body); var isPost = true; var errorstr = ""; if (isPost) { var result = MsOp_SuperVision_TruckDAL.DoSave(opstatus, headData, bodyList, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), Session["COMPANYNAME"].ToString()); if (result.Success) { var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = result.Data }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } else { var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } else { var jsonRespose = new JsonResponse { Success = false, Message = errorstr }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } public ContentResult Delete(string data) { var canlogin = BasicDataRefDAL.CheckLogin(Session); if (!canlogin.Success) { return (ContentResult)canlogin.Data; } var head = JsonConvert.Deserialize(data); var candelete = MsOp_SuperVision_TruckDAL.CanDelete(head); if (candelete.Success == false) { var _j = new JsonResponse(candelete); return new ContentResult() { Content = JsonConvert.Serialize(_j) }; } DBResult result = MsOp_SuperVision_TruckDAL.DoDelete(head); var jsonResponse = new JsonResponse(candelete); return new ContentResult() { Content = JsonConvert.Serialize(jsonResponse) }; } public ContentResult DeleteDetailList(string data) { var canlogin = BasicDataRefDAL.CheckLogin(Session); if (!canlogin.Success) { return (ContentResult)canlogin.Data; } var jsonResponse = new JsonResponse(); var bodylist = JsonConvert.Deserialize>(data); if (bodylist == null) { jsonResponse.Success = true; return new ContentResult() { Content = JsonConvert.Serialize(jsonResponse) }; } var detailgid = bodylist.Select(s => s.GID).ToArray(); var detailgidstr ="'"+ String.Join("','", detailgid) +"'"; var BSNO = bodylist[0].BSNO; var _c = BasicDataRefDAL.ExecSql("delete from OP_SuperVision_Truck_Detail where GID in(" + detailgidstr + ")"); //var head = MsOp_SuperVision_TruckDAL.GetData(" BSNO='" + BSNO + "'"); var currDetail = MsOp_SuperVision_TruckDAL.GetBodyList(" BSNO='" + BSNO + "'"); //head.setSum(currDetail); //head.setDate(); //head.DbOperationType = DbOperationType.DbotUpd; //head.ModelUIStatus = "E"; //var modb = new ModelObjectRepository(); //var _result = modb.Save(head); var jsonRespose = new JsonResponse { Success = true, Message = "删除成功!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult GetBodyList(string BSNO) { var canlogin = BasicDataRefDAL.CheckLogin(Session); if (!canlogin.Success) { return (ContentResult)canlogin.Data; } var count = 0; var condition = " BSNO='" + BSNO + "'"; var dataList = MsOp_SuperVision_TruckDAL.GetBodyList(condition); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } /// /// 获取一个新的分单号 并回传至前台 /// /// /// public ContentResult GetNewHBLNO(string BSNO) { var canlogin = BasicDataRefDAL.CheckLogin(Session); if (!canlogin.Success) { return (ContentResult)canlogin.Data; } var companyid = Session["COMPANYID"].ToString(); var result = MsOp_SuperVision_TruckDAL. GetNewHBLNO(BSNO, companyid); if (result.Success) { var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = result.Data }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } else { var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } #region 用excel批量上传车辆信息 public ContentResult ImportBodyList() { var canlogin = BasicDataRefDAL.CheckLogin(Session); if (!canlogin.Success) { return (ContentResult)canlogin.Data; } var jsonRespose = new JsonResponse { Success = false, Message = "" }; var dt = new DataTable(); var _r = BasicDataRefDAL.RequestExceltoDatatable(Request, out dt); var bsno = Request.Form["BSNO"]; if (_r.Success) { var _rn = MsOp_SuperVision_TruckDAL.InsertBodyList(bsno, dt); if (_rn >= 0) { jsonRespose.Success = true; jsonRespose.Message = $"成功上传{_rn.ToString()}条数据"; } } else { jsonRespose = new JsonResponse(_r); } return jsonRespose.getContentReult(); } #endregion } }