예제 #1
0
        public ActionResult CustomerEdit(CustomerInfoModel customerInfoModel)
        {
            if (Session["method"].ToString() == "Y")
            {
                string str = string.Format("<script>alert('重复操作!');parent.location.href='CustomerIndex';</script>");
                return(Content(str));
            }
            if (customerInfoModel == null)
            {
                return(Content("<script>alert('违规操作!!');window.history.go(-1);</script>"));
            }
            DateTimeFormatInfo dtFormat = new DateTimeFormatInfo
            {
                ShortDatePattern = "yyyy/MM/dd"
            };
            销售_接待记录 model = new 销售_接待记录();

            try
            {
                model.ID      = customerInfoModel.ID;
                model.店铺ID    = storeBLL.GetModel(p => p.称 == customerInfoModel.店铺).ID;
                model.接待人ID   = storeEmployeesBLL.GetModel(p => p.姓名 == customerInfoModel.接待人).ID;
                model.接待序号    = customerInfoModel.接待序号;
                model.接待日期    = Convert.ToDateTime(customerInfoModel.接待日期, dtFormat);
                model.主导者     = customerInfoModel.主导者;
                model.主导者喜好风格 = customerInfoModel.主导者喜好风格;
                model.使用空间    = customerInfoModel.使用空间;
                model.出店时间    = customerInfoModel.出店时间;
                model.制单日期    = customerInfoModel.制单日期;
                model.行人      = customerInfoModel.行人;
                model.如何得知品牌  = customerInfoModel.如何得知品牌;
                model.安装地址    = customerInfoModel.安装地址;
                model.客户姓名    = customerInfoModel.客户姓名;
                model.客户建议    = customerInfoModel.客户建议;
                model.客户来源    = customerInfoModel.客户来源;
                model.客户电话    = customerInfoModel.客户电话;
                model.客户着装    = customerInfoModel.客户着装;
                model.客户类别    = customerInfoModel.客户类别;
                model.客户类型    = customerInfoModel.客户类型;
                model.客户职业    = customerInfoModel.客户职业;
                model.家庭成员    = customerInfoModel.家庭成员;
                model.年龄段     = customerInfoModel.年龄段;
                model.性别      = customerInfoModel.性别;
                model.是否有意向   = customerInfoModel.是否有意向;
                if (customerInfoModel.更新人 != null)
                {
                    model.更新人 = storeEmployeesBLL.GetModel(p => p.姓名 == customerInfoModel.更新人).ID;
                }

                model.更新日期 = customerInfoModel.更新日期;
                model.来店次数 = customerInfoModel.来店次数;
                model.比较品牌 = customerInfoModel.比较品牌;
                model.特征   = customerInfoModel.特征;
                model.社交软件 = customerInfoModel.社交软件;
                model.装修情况 = customerInfoModel.装修情况;
                model.装修进度 = customerInfoModel.装修进度;
                model.装修风格 = customerInfoModel.装修风格;
                model.设计师  = customerInfoModel.设计师;
                if (customerInfoModel.跟进人 != null)
                {
                    model.跟进人ID = storeEmployeesBLL.GetModel(p => p.姓名 == customerInfoModel.跟进人).ID;
                }

                model.返点         = customerInfoModel.返点;
                model.进店时长       = customerInfoModel.进店时长;
                model.进店时间       = customerInfoModel.进店时间;
                model.预报价折扣      = customerInfoModel.预报价折扣;
                model.预算金额       = customerInfoModel.预算金额;
                model.预计使用时间     = customerInfoModel.预计使用时间;
                model.喜欢产品       = customerInfoModel.喜欢产品;
                model.喜欢元素       = customerInfoModel.喜欢元素;
                model.主卧预算备注     = customerInfoModel.主卧预算备注;
                model.主卧预算家具     = customerInfoModel.主卧预算家具;
                model.主卧预算金额     = customerInfoModel.主卧预算金额;
                model.书房预算备注     = customerInfoModel.书房预算备注;
                model.书房预算家具     = customerInfoModel.书房预算家具;
                model.书房预算金额     = customerInfoModel.书房预算金额;
                model.其它空间备注     = customerInfoModel.其它空间备注;
                model.其它空间家具     = customerInfoModel.其它空间家具;
                model.其它空间预算     = customerInfoModel.其它空间预算;
                model.喜欢产品       = customerInfoModel.喜欢产品;
                model.喜欢元素       = customerInfoModel.喜欢元素;
                model.婴儿或儿童房预算备注 = customerInfoModel.婴儿或儿童房预算备注;
                model.婴儿或儿童房预算家具 = customerInfoModel.婴儿或儿童房预算家具;
                model.婴儿或儿童房预算金额 = customerInfoModel.婴儿或儿童房预算金额;
                model.客厅预算备注     = customerInfoModel.客厅预算备注;
                model.客厅预算家具     = customerInfoModel.客厅预算家具;
                model.客厅预算金额     = customerInfoModel.客厅预算金额;
                model.户型大小       = customerInfoModel.户型大小;
                model.次卧预算备注     = customerInfoModel.次卧预算备注;
                model.次卧预算家具     = customerInfoModel.次卧预算家具;
                model.次卧预算金额     = customerInfoModel.次卧预算金额;
                model.比较品牌产品     = customerInfoModel.比较品牌产品;
                model.比较品牌产品备注   = customerInfoModel.比较品牌产品备注;
                if (ModelState.IsValid)
                {
                    customerInfoBLL.Modify(model);
                    Session["method"] = "Y";
                }

                else
                {
                    List <string> sb = new List <string>();
                    //获取所有错误的Key
                    List <string> Keys = ModelState.Keys.ToList();
                    //获取每一个key对应的ModelStateDictionary
                    foreach (var key in Keys)
                    {
                        var errors = ModelState[key].Errors.ToList();
                        //将错误描述添加到sb中
                        foreach (var error in errors)
                        {
                            sb.Add(error.ErrorMessage);
                        }
                    }
                    string s = null;
                    foreach (var item in sb)
                    {
                        s += item.ToString() + "<br/>";
                    }
                    return(Content("<script>alert('" + s + "');window.history.go(-1);</script>"));
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(RedirectToAction("CustomerIndex"));
        }
예제 #2
0
        public ActionResult CustomerAdd(CustomerInfoModel customerInfoModel)
        {
            if (Session["method"].ToString() == "Y")
            {
                string str = string.Format("<script>alert('重复操作!');parent.location.href='CustomerIndex';</script>");
                return(Content(str));
            }

            SetEmployee();
            var     employee = storeEmployeesBLL.GetModel(p => p.姓名 == employeeName);
            销售_接待记录 model    = new 销售_接待记录();

            try
            {
                model.店铺ID    = storeBLL.GetModel(p => p.称 == store).ID;
                model.接待人ID   = storeEmployeesBLL.GetModel(p => p.姓名 == employeeName).ID;
                model.接待序号    = customerInfoModel.接待序号;
                model.接待日期    = DateTime.Now.Date;
                model.主导者     = customerInfoModel.主导者;
                model.主导者喜好风格 = customerInfoModel.主导者喜好风格;
                model.使用空间    = customerInfoModel.使用空间;
                model.出店时间    = customerInfoModel.出店时间;
                model.制单日期    = DateTime.Now;
                model.行人      = customerInfoModel.行人;
                model.如何得知品牌  = customerInfoModel.如何得知品牌;
                model.安装地址    = customerInfoModel.安装地址;
                model.客户姓名    = customerInfoModel.客户姓名;
                model.客户建议    = customerInfoModel.客户建议;
                model.客户来源    = customerInfoModel.客户来源;
                model.客户电话    = customerInfoModel.客户电话;
                model.客户着装    = customerInfoModel.客户着装;
                model.客户类别    = customerInfoModel.客户类别;
                model.客户类型    = customerInfoModel.客户类型;
                model.客户职业    = customerInfoModel.客户职业;
                model.家庭成员    = customerInfoModel.家庭成员;
                model.年龄段     = customerInfoModel.年龄段;
                model.性别      = customerInfoModel.性别;
                model.是否有意向   = customerInfoModel.是否有意向;
                if (employeeName != null)
                {
                    model.更新人 = storeEmployeesBLL.GetModel(p => p.姓名 == employeeName).ID;
                }

                model.更新日期 = DateTime.Now;
                model.来店次数 = 1;
                model.比较品牌 = customerInfoModel.比较品牌;
                model.特征   = customerInfoModel.特征;
                model.社交软件 = customerInfoModel.社交软件;
                model.装修情况 = customerInfoModel.装修情况;
                model.装修进度 = customerInfoModel.装修进度;
                model.装修风格 = customerInfoModel.装修风格;
                model.设计师  = customerInfoModel.设计师;
                var recPersonID = storeEmployeesBLL.GetModel(p => p.姓名 == customerInfoModel.接待人).ID;
                if (storeEmployeesBLL.GetModel(p => p.姓名 == customerInfoModel.接待人).跟进目标计划数 > customerInfoBLL.GetModels(p => p.跟进人ID == recPersonID).Count())
                {
                    model.跟进人ID = storeEmployeesBLL.GetModel(p => p.姓名 == customerInfoModel.接待人).ID;//初次添加且当前接待人员跟进指标未满,跟进人为当前接待人员。否则为空。
                }



                model.返点         = customerInfoModel.返点;
                model.进店时长       = int.Parse((customerInfoModel.出店时间 - customerInfoModel.进店时间).TotalMinutes.ToString());
                model.进店时间       = customerInfoModel.进店时间;
                model.预报价折扣      = customerInfoModel.预报价折扣;
                model.预算金额       = customerInfoModel.预算金额;
                model.预计使用时间     = customerInfoModel.预计使用时间;
                model.喜欢产品       = customerInfoModel.喜欢产品;
                model.喜欢元素       = customerInfoModel.喜欢元素;
                model.主卧预算备注     = customerInfoModel.主卧预算备注;
                model.主卧预算家具     = customerInfoModel.主卧预算家具;
                model.主卧预算金额     = customerInfoModel.主卧预算金额;
                model.书房预算备注     = customerInfoModel.书房预算备注;
                model.书房预算家具     = customerInfoModel.书房预算家具;
                model.书房预算金额     = customerInfoModel.书房预算金额;
                model.其它空间备注     = customerInfoModel.其它空间备注;
                model.其它空间家具     = customerInfoModel.其它空间家具;
                model.其它空间预算     = customerInfoModel.其它空间预算;
                model.喜欢产品       = customerInfoModel.喜欢产品;
                model.喜欢元素       = customerInfoModel.喜欢元素;
                model.婴儿或儿童房预算备注 = customerInfoModel.婴儿或儿童房预算备注;
                model.婴儿或儿童房预算家具 = customerInfoModel.婴儿或儿童房预算家具;
                model.婴儿或儿童房预算金额 = customerInfoModel.婴儿或儿童房预算金额;
                model.客厅预算备注     = customerInfoModel.客厅预算备注;
                model.客厅预算家具     = customerInfoModel.客厅预算家具;
                model.客厅预算金额     = customerInfoModel.客厅预算金额;
                model.户型大小       = customerInfoModel.户型大小;
                model.次卧预算备注     = customerInfoModel.次卧预算备注;
                model.次卧预算家具     = customerInfoModel.次卧预算家具;
                model.次卧预算金额     = customerInfoModel.次卧预算金额;
                model.比较品牌产品     = customerInfoModel.比较品牌产品;
                model.比较品牌产品备注   = customerInfoModel.比较品牌产品备注;
            }
            catch (Exception e)
            {
                return(Content(e.Message));
            }



            if (!ModelState.IsValid)
            {
                List <string> sb = new List <string>();
                //获取所有错误的Key
                List <string> Keys = ModelState.Keys.ToList();
                //获取每一个key对应的ModelStateDictionary
                foreach (var key in Keys)
                {
                    var errors = ModelState[key].Errors.ToList();
                    //将错误描述添加到sb中
                    foreach (var error in errors)
                    {
                        sb.Add(error.ErrorMessage);
                    }
                }
                string s = null;
                foreach (var item in sb)
                {
                    s += item.ToString() + ";";
                }
                return(Content("<script>alert('" + s + "');window.history.go(-1);</script>"));
            }
            var isHave = customerInfoBLL.GetModel(p => p.客户姓名 == model.客户姓名 && p.接待日期 == model.接待日期);

            if (isHave != null)
            {
                return(Content("<script>alert('数据已存在!,请勿重复提交');parent.location.href='CustomerIndex';</script>"));
            }
            #region 如果客户已在当前店铺登记过
            try
            {
                var lis1 = customerInfoBLL.GetModels(p => p.客户姓名 == model.客户姓名 || p.客户电话 == model.客户电话);
                int num1 = lis1.Count();
                if (num1 >= 0) //统计客户来店登记次数
                {
                    model.来店次数 += num1;
                }
            }
            catch (Exception e)
            {
                return(Content(e.Message));
            }

            customerInfoBLL.Add(model);;
            Session["method"] = "Y";
            #endregion



            var id = customerInfoBLL.GetModel(p => p.接待序号 == model.接待序号).接待人ID;
            return(RedirectToAction("CustomerIndex"));
        }