/// <summary>
        /// 保存客户
        /// </summary>
        /// <returns>The customer.</returns>
        /// <param name="Data">Data.</param>
        public static int SaveCustomer(ActionRequest <CustomerSave> Data)
        {
            if (string.IsNullOrEmpty(Data.Body.SourceSysNo))
            {
                throw new Exception("SourceSysNo不能为空");
            }
            var Model = bllcustomer.GetModelList(string.Format("SourceSysNo='{0}'", PageValidate.SqlTextClear(Data.Body.SourceSysNo))).FirstOrDefault();

            if (Model == null)
            {
                return(bllcustomer.AddWithSysNo(new WebApi.Model.Customer()
                {
                    CellphoneNo = Data.Body.CellphoneNo ?? "",
                    CreateTime = DateTime.Now,
                    CustomerName = Data.Body.CustomerName ?? "",
                    SourceSysNo = PageValidate.SqlTextClear(Data.Body.SourceSysNo),
                    EditTime = DateTime.Now,
                    NickName = Data.Body.NickName ?? "",
                    JsonString = "",
                    Status = 1,
                }));
            }
            else
            {
                Model.CellphoneNo  = Data.Body.CellphoneNo ?? "";
                Model.CustomerName = Data.Body.CustomerName ?? "";
                Model.NickName     = Data.Body.NickName ?? "";
                Model.EditTime     = DateTime.Now;
                bllcustomer.Update(Model);
                return(Model.SysNo);
            }
        }
Exemple #2
0
        public void RaisePostBackEvent(string eventArgument)
        {
            if (eventArgument == "登录")
            {
                CustomerEmail = this.Customertx.Text;
                Password      = this.Passwordtx.Text;
                BLL.Customer          bllcustomer  = new BLL.Customer();
                List <Model.Customer> customerlist = bllcustomer.GetModelList("1=1");

                Model.Customer customer = new Model.Customer();
                customer.CustomerName = "123";
            }
        }
Exemple #3
0
        public void RaisePostBackEvent(string eventArgument)
        {
            if (eventArgument == "登录")
            {
                CustomerEmail = this.Customertx.Text;
                Password = this.Passwordtx.Text;
                BLL.Customer bllcustomer = new BLL.Customer();
                List<Model.Customer> customerlist = bllcustomer.GetModelList("1=1");

                Model.Customer customer = new Model.Customer();
                customer.CustomerName = "123";

            }
        }
Exemple #4
0
        public JsonObject Import(DataTable dt, DataTable dtTemplate)
        {
            JsonObject json = new JsonObject();

            if (dt == null || dt.Rows.Count == 0)
            {
                json.Status      = JsonObject.STATUS_FAIL;
                json.ErroMessage = "数据为空";
                return(json);
            }

            if (dtTemplate == null)
            {
                json.Status      = JsonObject.STATUS_FAIL;
                json.ErroMessage = "数据导入失败,模板错误,请联系管理员";
                return(json);
            }
            string checkTemplate = CommonHelper.Matching(dt, dtTemplate);

            if (checkTemplate != "")
            {
                json.Status      = JsonObject.STATUS_FAIL;
                json.ErroMessage = "数据导入失败," + checkTemplate + ",请下载最新模板";
                return(json);
            }
            StringBuilder         sbErro = new StringBuilder();
            List <Model.Customer> list   = new List <Model.Customer>();
            int parmInt = 0;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (i < dtTemplate.Rows.Count)
                {
                    //模板前几列不执行
                    continue;
                }
                bool checkNul = true;;
                for (int j = 0; j < dt.Columns.Count; j++)
                {
                    if (dt.Rows[i][j] != null && dt.Rows[i][j].ToString() != "")
                    {
                        checkNul = false;
                        break;
                    }
                }
                if (checkNul)
                {//如果行数据为空则忽略
                    continue;
                }
                StringBuilder sbErroI = new StringBuilder();
                //如果第一列为~开头,则为示例数据,不导入
                if (dt.Rows[i][0] != null && dt.Rows[i][0].ToString() != "" && dt.Rows[i][0].ToString().Substring(0, 1) == "~")
                {
                    continue;
                }
                Model.Customer model = new Model.Customer();
                if (dt.Rows[i]["客户名称"] != null && dt.Rows[i]["客户名称"].ToString().Trim() != "")
                {
                    model.CustomerName = dt.Rows[i]["客户名称"].ToString().Trim();
                }
                else
                {
                    sbErroI.Append(",客户名称不能为空");
                }
                if (dt.Rows[i]["联系人"] != null && dt.Rows[i]["联系人"].ToString().Trim() != "")
                {
                    model.Linkman = dt.Rows[i]["联系人"].ToString().Trim();
                }
                if (dt.Rows[i]["联系人电话"] != null && dt.Rows[i]["联系人电话"].ToString().Trim() != "")
                {
                    model.Telephone = dt.Rows[i]["联系人电话"].ToString().Trim();
                }
                if (dt.Rows[i]["排序"] != null && dt.Rows[i]["排序"].ToString().Trim() != "")
                {
                    if (int.TryParse(dt.Rows[i]["排序"].ToString().Trim(), out parmInt))
                    {
                        model.OrderBy = parmInt;
                    }
                    else
                    {
                        sbErroI.Append(",排序[" + dt.Rows[i]["排序"].ToString().Trim() + "]必须为数字");
                    }
                }
                if (dt.Rows[i]["备注"] != null && dt.Rows[i]["备注"].ToString().Trim() != "")
                {
                    model.Remark = dt.Rows[i]["备注"].ToString().Trim();
                }
                if (sbErroI.Length > 0)
                {
                    sbErro.Append(",第" + (i + 2) + "行数据:" + sbErroI.ToString().Substring(1));
                }
                list.Add(model);
            }
            //如果有错误信息
            if (sbErro.Length > 0)
            {
                json.Status      = JsonObject.STATUS_FAIL;
                json.ErroMessage = sbErro.ToString().Substring(1);
                return(json);
            }
            if (list.Count == 0)
            {
                json.Status      = JsonObject.STATUS_FAIL;
                json.ErroMessage = "数据为空";
                return(json);
            }
            try
            {
                int      addCount    = 0;
                int      updateCount = 0;
                string   userId      = CurrentUser.User.Userinfo.UserID;
                DateTime timeNow     = DateTime.Now;
                for (int i = 0; i < list.Count; i++)
                {
                    List <Model.Customer> modelExistsList = BLL.GetModelList("CustomerName='" + list[i].CustomerName + "' ");
                    if (modelExistsList != null && modelExistsList.Count > 0)
                    {
                        list[i].CustomerID   = modelExistsList[0].CustomerID;
                        list[i].CustomerName = modelExistsList[0].CustomerName;
                        list[i].CreateBy     = modelExistsList[0].CreateBy;
                        list[i].CreateTime   = modelExistsList[0].CreateTime;
                        list[i].UpdateBy     = userId;
                        list[i].UpdateTime   = timeNow;
                        BLL.Update(list[i]);
                        updateCount++;
                    }
                    else
                    {
                        list[i].CreateBy   = userId;
                        list[i].CreateTime = timeNow;
                        list[i].CustomerID = Guid.NewGuid().ToString();
                        BLL.Add(list[i]);
                        addCount++;
                    }
                }
                json.Status  = JsonObject.STATUS_SUCCESS;
                json.Message = "导入成功";
                if (addCount > 0)
                {
                    json.Message += ",添加" + addCount + "条数据";
                }
                if (updateCount > 0)
                {
                    json.Message += ",修改" + updateCount + "条数据";
                }
                return(json);
            }
            catch (Exception ex)
            {
                json.Status      = JsonObject.STATUS_FAIL;
                json.ErroMessage = "导入失败,失败原因:" + ex.Message;
                return(json);
            }
            finally
            {
            }
        }
Exemple #5
0
        /// <summary>
        /// 保存数据字典数据
        /// </summary>
        /// <returns></returns>
        public ActionResult Save(Model.Customer model)
        {
            JsonObject    json   = new JsonObject();
            StringBuilder sbErro = new StringBuilder();

            if (string.IsNullOrEmpty(model.CustomerName))
            {
                sbErro.Append(",客户名称不能为空");
            }
            if (sbErro.Length > 0)
            {
                json.Status      = JsonObject.STATUS_FAIL;
                json.ErroMessage = sbErro.ToString().Substring(1);
                return(Json(json));
            }
            //如果ID为空,则是添加
            if (string.IsNullOrEmpty(model.CustomerID))
            {
                //DepartmentName 唯一
                List <Model.Customer> modelExistsList = BLL.GetModelList("CustomerName='" + model.CustomerName + "'");
                if (modelExistsList != null && modelExistsList.Count > 0)
                {
                    json.Status      = JsonObject.STATUS_FAIL;
                    json.ErroMessage = "添加失败,此数据已存在";
                    return(Json(json));
                }
                model.CreateTime = DateTime.Now;
                model.CreateBy   = CurrentUser.User.Userinfo.UserID;
                model.CustomerID = Guid.NewGuid().ToString();
                bool res = BLL.Add(model);
                if (res)
                {
                    json.Status  = JsonObject.STATUS_SUCCESS;
                    json.Message = "添加成功";
                    return(Json(json));
                }
                else
                {
                    json.Status      = JsonObject.STATUS_FAIL;
                    json.ErroMessage = "添加失败";
                    return(Json(json));
                }
            }
            else
            {
                //value 和 type 唯一确定一个text值
                List <Model.Customer> modelExistsList = BLL.GetModelList("CustomerName='" + model.CustomerName + "' and CustomerID!='" + model.CustomerID + "'");
                if (modelExistsList != null && modelExistsList.Count > 0)
                {
                    json.Status      = JsonObject.STATUS_FAIL;
                    json.ErroMessage = "添加失败,此数据已存在";
                    return(Json(json));
                }
                Model.Customer modelOld = BLL.GetModel(model.CustomerID);
                if (modelOld == null)
                {
                    json.Status      = JsonObject.STATUS_FAIL;
                    json.ErroMessage = "数据不存在";
                    return(Json(json));
                }
                modelOld.CustomerName = model.CustomerName;
                modelOld.Linkman      = model.Linkman;
                modelOld.Telephone    = model.Telephone;
                modelOld.OrderBy      = model.OrderBy;
                modelOld.Remark       = model.Remark;
                modelOld.UpdateTime   = DateTime.Now;
                modelOld.UpdateBy     = CurrentUser.User.Userinfo.UserID;
                bool res = BLL.Update(modelOld);
                if (res)
                {
                    json.Status  = JsonObject.STATUS_SUCCESS;
                    json.Message = "修改成功";
                    return(Json(json));
                }
                else
                {
                    json.Status      = JsonObject.STATUS_FAIL;
                    json.ErroMessage = "修改失败";
                    return(Json(json));
                }
            }
        }