Exemplo n.º 1
0
        protected void btnSave_Click1(object sender, EventArgs e)
        {
            #region 数据验证
            string msg = "请选择图片文件";
            if (!EyouSoft.Common.Function.UploadFile.CheckFileType(Request.Files, "car_img", new[] { ".jpg", ".png", ".gif", ".bmp", ".jpeg" }, null, out msg))
            {
                EyouSoft.Common.Function.MessageBox.ResponseScript(this, Utils.ShowMsg("请选择图片文件上传!"));
                return;
            }
            #endregion


            //创建车辆信息类

            //创建车队信息类
            EyouSoft.Model.SupplierStructure.SupplierCarTeam carTeam = new EyouSoft.Model.SupplierStructure.SupplierCarTeam();


            if (Utils.GetInt(Utils.GetQueryStringValue("cid")) != 0)
            {
                carTeam = carTeamBll.GetCarTeamInfo(cid);
            }


            //获取页面上所有联系人的信息
            IList <EyouSoft.Model.CompanyStructure.SupplierContact> contacts = new List <EyouSoft.Model.CompanyStructure.SupplierContact>();
            string[] linkman_names     = Utils.GetFormValues("linkman_name");
            string[] linkman_bussiness = Utils.GetFormValues("linkman_bussiness");
            string[] linkman_phone     = Utils.GetFormValues("linkman_phone");
            string[] linkman_tel       = Utils.GetFormValues("linkman_tel");
            string[] linkman_qq        = Utils.GetFormValues("linkman_qq");
            string[] linkman_email     = Utils.GetFormValues("linkman_email");
            string[] linkman_fax       = Utils.GetFormValues("linkman_fax");
            //判断页面上添加联系人的数量
            if (linkman_names.Length >= 1)
            {
                for (int i = 0; i < linkman_names.Length; i++)
                {
                    //创建供应商联系人类
                    EyouSoft.Model.CompanyStructure.SupplierContact contact = new EyouSoft.Model.CompanyStructure.SupplierContact();
                    contact.QQ            = linkman_qq[i];
                    contact.Email         = linkman_email[i];
                    contact.ContactName   = linkman_names[i];
                    contact.ContactMobile = linkman_phone[i];
                    contact.ContactTel    = linkman_tel[i];
                    contact.JobTitle      = linkman_bussiness[i];
                    contact.ContactFax    = linkman_fax[i];
                    contacts.Add(contact);
                }
            }
            //获取页面上所有车辆的信息
            IList <EyouSoft.Model.SupplierStructure.SupplierCarInfo> carInfos = new List <EyouSoft.Model.SupplierStructure.SupplierCarInfo>();
            string[] car_types        = Utils.GetFormValues("car_type");
            string[] car_nums         = Utils.GetFormValues("car_num");
            string[] car_prices       = Utils.GetFormValues("car_price");
            string[] car_drivers      = Utils.GetFormValues("car_driver");
            string[] car_driverPhones = Utils.GetFormValues("car_driverPhone");
            string[] car_worlds       = Utils.GetFormValues("car_world");
            string[] hid_img          = Utils.GetFormValues("hid_img");

            //判断页面上的添加车辆的数量
            if (car_types.Length >= 1)
            {
                for (int i = 0; i < car_types.Length; i++)
                {
                    EyouSoft.Model.SupplierStructure.SupplierCarInfo carInfo = new EyouSoft.Model.SupplierStructure.SupplierCarInfo();
                    string imagePath = "";
                    string imgName   = "";
                    EyouSoft.Common.Function.UploadFile.FileUpLoad(Request.Files[i], "CarFile", out imagePath, out imgName);
                    carInfo.CarNumber   = car_nums[i];
                    carInfo.CarType     = car_types[i];
                    carInfo.DriverName  = car_drivers[i];
                    carInfo.DriverPhone = car_driverPhones[i];
                    carInfo.GuideWord   = car_worlds[i];
                    if (imagePath == "" && hid_img[i] != "")
                    {
                        carInfo.Image = hid_img[i];
                    }
                    else
                    {
                        carInfo.Image = imagePath;
                    }

                    carInfo.Price      = Utils.GetDecimal(car_prices[i], 0);
                    carInfo.PrivaderId = SiteUserInfo.CompanyID;
                    carInfos.Add(carInfo);
                }
            }

            carTeam.CarsInfo        = carInfos;
            carTeam.SupplierContact = contacts;
            carTeam.Remark          = Utils.GetFormValue("companyRemark");
            carTeam.UnitAddress     = Utils.GetFormValue("companyAddress");
            carTeam.UnitName        = Utils.GetFormValue("companyName");
            carTeam.CityId          = Utils.GetInt(this.city_id.Value);
            carTeam.SupplierType    = EyouSoft.Model.EnumType.CompanyStructure.SupplierType.车队;
            carTeam.CompanyId       = SiteUserInfo.CompanyID;
            carTeam.ProvinceId      = Utils.GetInt(this.pro_id.Value);
            //设置车队信息的省份名字
            EyouSoft.Model.CompanyStructure.Province Provincemodel = new EyouSoft.BLL.CompanyStructure.Province().GetModel(this.ucProvince1.ProvinceId);
            if (Provincemodel != null)
            {
                carTeam.ProvinceName = Provincemodel.ProvinceName;
            }
            //设置车队信息的城市名字
            EyouSoft.Model.CompanyStructure.City citymodel = new EyouSoft.BLL.CompanyStructure.City().GetModel(this.ucCity1.CityId);
            if (citymodel != null)
            {
                carTeam.CityName = citymodel.CityName;
            }
            int result = 0;
            if (Utils.GetInt(Utils.GetQueryStringValue("cid")) != 0)
            {
                result = carTeamBll.UpdateCarTeam(carTeam);
            }
            else
            {
                result = carTeamBll.InsertCarTeamInfo(carTeam);
            }

            if (result > 0)
            {
                MessageBox.ResponseScript(this, string.Format(";alert('{0}');window.parent.location='/SupplierControl/CarsManager/CarsList.aspx';window.parent.Boxy.getIframeDialog('{1}').hide()", "保存成功", Utils.GetQueryStringValue("iframeId")));
            }
            else
            {
                MessageBox.ResponseScript(this, ";alert('保存失败!');");
            }
        }
Exemplo n.º 2
0
        private void loadXls()
        {
            //取得数据源
            string data = Utils.GetFormValue("dataxls");

            //对数据源分割处理
            string[] s = data.Split(';');
            EyouSoft.BLL.SupplierStructure.SupplierCarTeam carTeamBll = new EyouSoft.BLL.SupplierStructure.SupplierCarTeam();

            IList <EyouSoft.Model.SupplierStructure.SupplierCarTeam> list = new List <EyouSoft.Model.SupplierStructure.SupplierCarTeam>();

            //为list集合赋值
            for (int i = 0; i < s.Length; i++)
            {
                string[] smodel = s[i].Split(',');

                if (smodel.Length == 17 && !string.IsNullOrEmpty(smodel[0]) && !string.IsNullOrEmpty(smodel[1]) && !string.IsNullOrEmpty(smodel[2]))
                {
                    EyouSoft.Model.SupplierStructure.SupplierCarTeam        carteamInfo = new EyouSoft.Model.SupplierStructure.SupplierCarTeam();
                    EyouSoft.Model.CompanyStructure.SupplierContact         contact = new EyouSoft.Model.CompanyStructure.SupplierContact();
                    EyouSoft.Model.SupplierStructure.SupplierCarInfo        carInfo = new EyouSoft.Model.SupplierStructure.SupplierCarInfo(); IList <EyouSoft.Model.SupplierStructure.SupplierCarInfo> carInfos = new List <EyouSoft.Model.SupplierStructure.SupplierCarInfo>();
                    IList <EyouSoft.Model.CompanyStructure.SupplierContact> contacts = new List <EyouSoft.Model.CompanyStructure.SupplierContact>();
                    carteamInfo.ProvinceName = HttpUtility.UrlDecode(smodel[0]);
                    carteamInfo.CityName     = HttpUtility.UrlDecode(smodel[1]);
                    carteamInfo.UnitName     = HttpUtility.UrlDecode(smodel[2]);
                    carteamInfo.UnitAddress  = HttpUtility.UrlDecode(smodel[3]);
                    carInfo.GuideWord        = HttpUtility.UrlDecode(smodel[4]);
                    contact.ContactName      = HttpUtility.UrlDecode(smodel[5]);
                    contact.JobTitle         = HttpUtility.UrlDecode(smodel[6]);
                    contact.ContactTel       = HttpUtility.UrlDecode(smodel[7]);
                    contact.ContactMobile    = HttpUtility.UrlDecode(smodel[8]);
                    contact.QQ               = HttpUtility.UrlDecode(smodel[9]);
                    contact.Email            = HttpUtility.UrlDecode(smodel[10]);
                    carInfo.CarType          = HttpUtility.UrlDecode(smodel[11]);
                    carInfo.CarNumber        = HttpUtility.UrlDecode(smodel[12]);
                    carInfo.Price            = Utils.GetDecimal(HttpUtility.UrlDecode(smodel[13]));
                    carInfo.DriverName       = HttpUtility.UrlDecode(smodel[14]);
                    carInfo.DriverPhone      = HttpUtility.UrlDecode(smodel[15]);
                    carteamInfo.Remark       = HttpUtility.UrlDecode(smodel[16]);
                    carteamInfo.SupplierType = EyouSoft.Model.EnumType.CompanyStructure.SupplierType.车队;
                    carteamInfo.TradeNum     = 0;
                    carteamInfo.CompanyId    = SiteUserInfo.CompanyID;
                    carInfos.Add(carInfo);
                    contacts.Add(contact);
                    carteamInfo.CarsInfo        = carInfos;
                    carteamInfo.SupplierContact = contacts;
                    list.Add(carteamInfo);
                }
            }
            int res = 0;

            //导入从excel获得数据
            res = carTeamBll.InsertCarTeams(list);
            bool result = false;

            if (res > 0)
            {
                result = true;
            }

            Response.Clear();
            Response.Write(string.Format("{{\"res\":{0}}}", result ? 1 : -1));
            Response.End();
        }