示例#1
0
        public string AddCarAndTer(TerminalBind tb)
        {
            UserInfo user = new UserInfo();

            user = (UserInfo)Session["LoginUser"];
            if (user != null)
            {
                if (tb.DeptId != null && tb.DeptId.Trim() == "")
                {
                    tb.DeptId = user.EnterId;
                }
                DeptInfoBLL deptInfoBll = new DeptInfoBLL();
                DeptInfo    di          = deptInfoBll.GetDeptInfo(tb.DeptId);
                string      deptcode    = di.Businessdivisioncode;
                tb.Businessdivisioncode = deptcode;
                string     carinfostr = "";
                CarTypeBLL cartypebll = new CarTypeBLL();
                CarType    ct         = cartypebll.GetCarType(tb.TypeId);
                if (ct != null)
                {
                    carinfostr = ct.TypeName + "||||||||||||||||||||||||||||||";
                }
                string result = tib.AddCarAndTer(tb);

                new LogMessage().Save("TerNo:" + tb.TerNo + "。");

                if (result == "true")
                {
                    //绑车接口
                    Transfers.ClintSendCommData(1107, "50", "", tb.CarNo, "", "", "", "", "", "", "", deptcode, tb.CarNo, carinfostr, "", "", "", "", user.UserName);

                    //刷新车辆
                    Transfers.ClintSendCommData(1160, "1108", "", "", "", "", "", "", "", "", "", "1", "2", "", "", "", "", "", "");
                }
                return(result);
            }
            else
            {
                return("false");
            }
        }
        public ActionResult UpLoadCarInfoForm(string DeptId, HttpPostedFileBase file)
        {
            UserInfo user = new UserInfo();

            user = (UserInfo)Session["LoginUser"];
            if (file != null && file.ContentLength > 0 && DeptId != null && DeptId.Trim() != "")
            {
                string filePath = Path.Combine(HttpContext.Server.MapPath("../Files"), System.Guid.NewGuid().ToString() + Path.GetExtension(file.FileName));

                file.SaveAs(filePath);

                new LogMessage().Save("文件:" + filePath + ";");

                string val = "";
                string msg = "";

                ExcelUpLoad eu = new ExcelUpLoad();

                List <UpLoadTerBind> lut = eu.ReadCarInfo_ZNX(filePath, ref msg);
                if (lut != null && lut.Count > 0)
                {
                    val = carInfoBll.insertCarInfoMul(DeptId, lut);
                    if (val.LastIndexOf(",") > 0)
                    {
                        val = val.Substring(0, val.Length - 1);
                    }
                    ViewBag.ReturnVal = val;

                    //绑车接口
                    for (int i = 0; i < lut.Count; i++)
                    {
                        string CarDeptcode = "";
                        string TypeName    = "";
                        if (lut[i].BusinessDivisionId != "" && lut[i].BusinessDivisionId != null)
                        {
                            DeptInfo di = deptInfoBll.GetDeptInfo(lut[i].BusinessDivisionId);
                            CarDeptcode = di.Businessdivisioncode;
                        }
                        if (lut[i].CarType != "" && lut[i].CarType != null)
                        {
                            CarTypeBLL cartypebll = new CarTypeBLL();
                            CarType    ct         = cartypebll.GetCarType(lut[i].CarType);
                            if (ct != null)
                            {
                                TypeName = ct.TypeName;
                            }
                        }

                        string carinfostr = TypeName + "|" + lut[i].CarColor + "|||||||||||||||||||||||||||||";

                        Transfers.ClintSendCommData(1107, "50", "", lut[i].TerNo, "", "", "", "", "", "", "", CarDeptcode, lut[i].CarNo, carinfostr, lut[i].CarAdminName, lut[i].CarFrame, "", "", user.UserName);
                    }
                }
                else if (msg.Trim() != "")
                {
                    if (msg.LastIndexOf(",") > 0)
                    {
                        msg = msg.Substring(0, msg.Length - 1);
                    }
                    ViewBag.ReturnVal = msg;
                }
                else
                {
                    ViewBag.ReturnVal = "false";
                }
            }
            else if (DeptId == null || DeptId.Trim() == "")
            {
                ViewBag.ReturnVal = "请选择导入车辆的所属企业!";
            }
            else if (file == null || file.ContentLength <= 0)
            {
                ViewBag.ReturnVal = "请选择要导入的文件!";
            }
            //刷新车辆
            Transfers.ClintSendCommData(1160, "1108", "", "", "", "", "", "", "", "", "", "1", "2", "", "", "", "", "", "");
            return(View());
        }