示例#1
0
        private string DoAdd(out int cid)
        {
            cid = 0;
            Model.Customer model = new Model.Customer();
            BLL.Customer   bll   = new BLL.Customer();

            manager           = GetAdminInfo();
            model.c_name      = txtName.Text.Trim();
            model.c_type      = (byte)Utils.ObjToInt(ddltype.SelectedValue);
            model.c_num       = txtNum.Text.ToString();
            model.c_isUse     = cbIsUse.Checked;
            model.c_remarks   = txtRemark.Text.Trim();
            model.c_flag      = 0;
            model.c_owner     = manager.user_name;
            model.c_ownerName = manager.real_name;
            model.c_addDate   = DateTime.Now;
            model.c_business  = txtBusinessScope.Text.Trim();

            Model.Contacts contact = new Model.Contacts();
            contact.co_flag   = true;
            contact.co_name   = txtMContact.Text.Trim();
            contact.co_number = txtMPhone.Text.Trim();

            return(bll.Add(model, contact, manager, out cid));
        }
示例#2
0
        private bool DoAdd()
        {
            bool result = false;

            Model.Customer model = new Model.Customer();
            BLL.Customer   bll   = new BLL.Customer();

            model.TypeName              = ddlTypeName.SelectedValue;
            model.ShortName             = txtShortName.Text.Trim();
            model.FullName              = txtFullName.Text.Trim();
            model.Category              = ddlCategory.SelectedValue;
            model.Code                  = string.IsNullOrEmpty(txtCode.Text.Trim()) ? "" : txtCode.Text.Trim();
            model.LinkMan               = txtLinkMan.Text.Trim();
            model.LinkTel               = txtLinkTel.Text.Trim();
            model.LinkAddress           = txtLinkAddress.Text.Trim();
            model.MobileNumber          = txtMobileNumber.Text.Trim();
            model.TaxRegistrationNumber = txtTaxRegistrationNumber.Text.Trim();
            model.Remarks               = txtRemarks.Text.Trim();

            if (bll.Add(model) > 0)
            {
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加客户:" + model.ShortName); //记录日志
                result = true;
            }
            return(result);
        }
示例#3
0
        /// <summary>
        /// 提交
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            bool isEdit = false;

            if (int.TryParse(Request.Params["id"], out id))
            {
                model  = bll.GetModel(id);
                isEdit = true;
            }
            else
            {
                model.NumId   = bll.SetNumID();
                model.AddTime = DateTime.Now;
            }

            model.Addressinfo = txtAddress.Text;
            model.CompanyName = txtCompanyName.Text;
            model.Email       = txtEmail.Text;
            model.Explain     = txtExplain.Text;
            model.NameInfo    = txtNameInfo.Text;
            model.Phone       = txtPhone.Text;
            model.QQNum       = txtQQ.Text;
            model.ParentId    = int.Parse(ddlParentID.SelectedValue);
            model.StateInfo   = ckState.Checked ? 1 : 0;
            model.Tel         = "";

            model.WeChat   = txtWechat.Text;
            model.SourceId = 10013;
            if (isEdit)
            {
                if (bll.Update(model))
                {
                    JsMessage("客户信息修改成功", 2000, "true", "index.aspx" + Request.Url.Query);
                }
                else
                {
                    JsMessage("客户信息修改失败,请稍候重试", 2000, "false");
                }
            }
            else
            {
                if (bll.Add(model) > 0)
                {
                    JsMessage("客户信息录入成功", 2000, "true", "index.aspx");
                }
                else
                {
                    JsMessage("客户信息录入失败,请稍候重试", 2000, "false");
                }
            }
        }
示例#4
0
        private bool DoAdd()
        {
            bool result = false;

            Model.Customer model = new Model.Customer();
            BLL.Customer   bll   = new BLL.Customer();

            model.Code        = txtCode.Text;
            model.Name        = txtName.Text;
            model.LinkMan     = txtLinkMan.Text;
            model.LinkTel     = txtLinkTel.Text;
            model.LinkAddress = txtLinkAddress.Text;
            model.Email       = txtEmail.Text;
            model.Fax         = txtFax.Text;
            model.Status      = Convert.ToInt32(rblStatus.SelectedValue);
            model.Remark      = txtRemark.Text;
            if (bll.Add(model))
            {
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加客户:" + model.Name); //记录日志
                result = true;
            }
            return(result);
        }
示例#5
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
            {
            }
        }
示例#6
0
        private bool DoAdd()
        {
            bool result = false;
            Model.Customer model = new Model.Customer();
            BLL.Customer bll = new BLL.Customer();

            model.Code = txtCode.Text;
            model.Name = txtName.Text;
            model.LinkMan = txtLinkMan.Text;
            model.LinkTel = txtLinkTel.Text;
            model.LinkAddress = txtLinkAddress.Text;
            model.Email = txtEmail.Text;
            model.Fax = txtFax.Text;
            model.Status = Convert.ToInt32(rblStatus.SelectedValue);
            model.Remark = txtRemark.Text;
            if (bll.Add(model))
            {
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加客户:" + model.Name); //记录日志
                result = true;
            }
            return result;
        }
示例#7
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));
                }
            }
        }