private void FixupCustomer(Customer previousValue)
        {
            if (IsDeserializing)
            {
                return;
            }

            if (previousValue != null && previousValue.SalesOrderHeaders.Contains(this))
            {
                previousValue.SalesOrderHeaders.Remove(this);
            }

            if (Customer != null)
            {
                if (!Customer.SalesOrderHeaders.Contains(this))
                {
                    Customer.SalesOrderHeaders.Add(this);
                }

                CustomerID = Customer.CustomerID;
            }
            if (ChangeTracker.ChangeTrackingEnabled)
            {
                if (ChangeTracker.OriginalValues.ContainsKey("Customer")
                    && (ChangeTracker.OriginalValues["Customer"] == Customer))
                {
                    ChangeTracker.OriginalValues.Remove("Customer");
                }
                else
                {
                    ChangeTracker.RecordOriginalValue("Customer", previousValue);
                }
                if (Customer != null && !Customer.ChangeTracker.ChangeTrackingEnabled)
                {
                    Customer.StartTracking();
                }
            }
        }
Example #2
0
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }

            Model.Customer model = new Model.Customer();
            model.GUID = new Guid(this.dataGridView1[0, 
                this.dataGridView1.CurrentRow.Index].Value.ToString());
            frmCustomer frm = new frmCustomer(model);
            frm.ShowDialog(frmMain.Main);
        }
Example #3
0
 public OperationStatus SaveCustomer(Customer customer)
 {
     return new CustomerRepository().SaveCustomer(customer);
 }
Example #4
0
        private void GetCustomerGroupAndSelected(Guid guid)
        {
            //获得所属客户组
            BLL.Customer bllCustomer = new BLL.Customer();
            BLL.CustomerGroup bllGroup = new BLL.CustomerGroup();

            Model.Customer modelCustomer = new Model.Customer();
            modelCustomer = bllCustomer.GetModel(guid);

            List<string> lst = new List<string>();
            bllGroup.GetSelected(ref lst, modelCustomer.parentGUID);

            StringBuilder sb = new StringBuilder();

            for (int i = lst.Count - 1; i > 0; i--)
            {
                sb.Append(lst[i]);
                sb.Append(this.cbxCustomerGroup.BranchSeparator);
            }

            sb.Append(lst[0]);

            this.cbxCustomerGroup.Text = sb.ToString();
            this.cbxCustomerGroup.SelectedNode =
                (this.cbxCustomerGroup.Nodes.Find(
                modelCustomer.parentGUID.ToString(), true))[0];

            cbxCustomerGroup_Leave(null, null);

            cbxName.SelectedValue = guid.ToString();
        }
Example #5
0
 public OperationStatus SaveCustomer(Customer customer)
 {
     return _Repository.SaveCustomer(customer);
 }
Example #6
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            errorProvider1.Clear();

            if (string.IsNullOrEmpty(this.txtNO.Text.Trim()))
            {
                errorProvider1.SetError(txtNO, "客户编号不能为空!");
                return;
            }

            if (string.IsNullOrEmpty(this.txtName.Text.Trim()))
            {
                errorProvider1.SetError(txtName, "客户名称不能为空!");
                return;
            }

            if (!this.cbxCustomerGroup.ValidateText())
            {
                errorProvider1.SetError(cbxCustomerGroup,
                    "必须选择所属客户组!");
                return;
            }

            BLL.Customer bll = new BLL.Customer();
            Model.Customer model = new Model.Customer();
            model.cNO = txtNO.Text.Substring(txtNO.Text.Length - 4);
            model.cName = txtName.Text.Trim();
            model.parentGUID = new Guid(this.cbxCustomerGroup.SelectedNode.Name);
            if (cbxIsGov.Text != "政府")
            {
                model.isGov = false;
            }
            else
            {
                model.isGov = true;
            }
            model.trade = txtTrade.Text.Trim();
            model.cMan = txtMan.Text.Trim();
            model.Tel = txtTel.Text.Trim();
            model.fax = txtFax.Text.Trim();
            model.email = txtEmail.Text.Trim();
            model.province = cbxProvince.Text;
            model.city = cbxCity.Text;
            model.district = cbxDistrict.Text;
            model.QQ = txtQQ.Text.Trim();
            model.mode = txtMode.Text.Trim();
            model.scope = txtScope.Text.Trim();
            model.product = txtProduct.Text.Trim();
            model.addresss = txtAddress.Text.Trim();
            model.cStage = cbxStage.Text;
            model.cType = cbxType.Text;
            model.cLevel = cbxLevel.Text;
            model.cStatus = cbxStatus.Text;
            model.link1 = txtLink1.Text.Trim();
            model.tel1 = txtTel1.Text.Trim();
            model.link2 = txtLink2.Text.Trim();
            model.tel2 = txtTel2.Text.Trim();

            bool flg = false;

            try
            {
                if (this.Text == "新增客户信息")
                {
                    flg = bll.Add(model);
                }
                else
                {
                    model.GUID = _model.GUID;
                    flg = bll.Update(model);
                }

            }
            catch (Exception ex)
            {
                string error = ex.Message;
                MessageBox.Show("系统出错,请重试!");
                return;
            }

            if (flg)
            {
                MessageBox.Show("操作成功!");
            }
            else
            {
                MessageBox.Show("操作失败!");
            }

            if (((Control)sender).Name == "btnSave")
            {
                this.Close();
                this.Dispose();
                frmCustomer frm = new frmCustomer(_guid);
                frm.ShowDialog(frmMain.Main);
            }
            else
            {
                this.Close();
            }

            //刷新激活的窗体
            for (int i = 0; i < frmMain.Main.DockPanelMain.Contents.Count; i++)
            {
                if (frmMain.Main.DockPanelMain.Contents[i] 
                    is dockCustomer)
                {
                    dockCustomer dock = (dockCustomer)
                        frmMain.Main.DockPanelMain.Contents[i];
                    dock.GetData();
                }
            }
        }
Example #7
0
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<CustomerService.Model.Customer> DataTableToList(DataTable dt)
		{
			List<CustomerService.Model.Customer> modelList = new List<CustomerService.Model.Customer>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				CustomerService.Model.Customer model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new CustomerService.Model.Customer();
					if(dt.Rows[n]["GUID"]!=null && dt.Rows[n]["GUID"].ToString()!="")
					{
						model.GUID=new Guid(dt.Rows[n]["GUID"].ToString());
					}
					if(dt.Rows[n]["cNO"]!=null && dt.Rows[n]["cNO"].ToString()!="")
					{
					model.cNO=dt.Rows[n]["cNO"].ToString();
					}
					if(dt.Rows[n]["parentGUID"]!=null && dt.Rows[n]["parentGUID"].ToString()!="")
					{
						model.parentGUID=new Guid(dt.Rows[n]["parentGUID"].ToString());
					}
					if(dt.Rows[n]["cName"]!=null && dt.Rows[n]["cName"].ToString()!="")
					{
					model.cName=dt.Rows[n]["cName"].ToString();
					}
					if(dt.Rows[n]["cMan"]!=null && dt.Rows[n]["cMan"].ToString()!="")
					{
					model.cMan=dt.Rows[n]["cMan"].ToString();
					}
					if(dt.Rows[n]["Tel"]!=null && dt.Rows[n]["Tel"].ToString()!="")
					{
					model.Tel=dt.Rows[n]["Tel"].ToString();
					}
					if(dt.Rows[n]["isGov"]!=null && dt.Rows[n]["isGov"].ToString()!="")
					{
						if((dt.Rows[n]["isGov"].ToString()=="1")||(dt.Rows[n]["isGov"].ToString().ToLower()=="true"))
						{
						model.isGov=true;
						}
						else
						{
							model.isGov=false;
						}
					}
					if(dt.Rows[n]["trade"]!=null && dt.Rows[n]["trade"].ToString()!="")
					{
					model.trade=dt.Rows[n]["trade"].ToString();
					}
					if(dt.Rows[n]["deptUp"]!=null && dt.Rows[n]["deptUp"].ToString()!="")
					{
					model.deptUp=dt.Rows[n]["deptUp"].ToString();
					}
					if(dt.Rows[n]["cType"]!=null && dt.Rows[n]["cType"].ToString()!="")
					{
					model.cType=dt.Rows[n]["cType"].ToString();
					}
					if(dt.Rows[n]["cStage"]!=null && dt.Rows[n]["cStage"].ToString()!="")
					{
					model.cStage=dt.Rows[n]["cStage"].ToString();
					}
					if(dt.Rows[n]["cStatus"]!=null && dt.Rows[n]["cStatus"].ToString()!="")
					{
					model.cStatus=dt.Rows[n]["cStatus"].ToString();
					}
					if(dt.Rows[n]["cLevel"]!=null && dt.Rows[n]["cLevel"].ToString()!="")
					{
					model.cLevel=dt.Rows[n]["cLevel"].ToString();
					}
					if(dt.Rows[n]["province"]!=null && dt.Rows[n]["province"].ToString()!="")
					{
					model.province=dt.Rows[n]["province"].ToString();
					}
					if(dt.Rows[n]["city"]!=null && dt.Rows[n]["city"].ToString()!="")
					{
					model.city=dt.Rows[n]["city"].ToString();
					}
					if(dt.Rows[n]["district"]!=null && dt.Rows[n]["district"].ToString()!="")
					{
					model.district=dt.Rows[n]["district"].ToString();
					}
					if(dt.Rows[n]["fax"]!=null && dt.Rows[n]["fax"].ToString()!="")
					{
					model.fax=dt.Rows[n]["fax"].ToString();
					}
					if(dt.Rows[n]["addresss"]!=null && dt.Rows[n]["addresss"].ToString()!="")
					{
					model.addresss=dt.Rows[n]["addresss"].ToString();
					}
					if(dt.Rows[n]["zip"]!=null && dt.Rows[n]["zip"].ToString()!="")
					{
					model.zip=dt.Rows[n]["zip"].ToString();
					}
					if(dt.Rows[n]["netSet"]!=null && dt.Rows[n]["netSet"].ToString()!="")
					{
					model.netSet=dt.Rows[n]["netSet"].ToString();
					}
					if(dt.Rows[n]["email"]!=null && dt.Rows[n]["email"].ToString()!="")
					{
					model.email=dt.Rows[n]["email"].ToString();
					}
					if(dt.Rows[n]["QQ"]!=null && dt.Rows[n]["QQ"].ToString()!="")
					{
					model.QQ=dt.Rows[n]["QQ"].ToString();
					}
					if(dt.Rows[n]["mode"]!=null && dt.Rows[n]["mode"].ToString()!="")
					{
					model.mode=dt.Rows[n]["mode"].ToString();
					}
					if(dt.Rows[n]["scope"]!=null && dt.Rows[n]["scope"].ToString()!="")
					{
					model.scope=dt.Rows[n]["scope"].ToString();
					}
					if(dt.Rows[n]["product"]!=null && dt.Rows[n]["product"].ToString()!="")
					{
					model.product=dt.Rows[n]["product"].ToString();
					}
					if(dt.Rows[n]["opponent"]!=null && dt.Rows[n]["opponent"].ToString()!="")
					{
					model.opponent=dt.Rows[n]["opponent"].ToString();
					}
					if(dt.Rows[n]["credit"]!=null && dt.Rows[n]["credit"].ToString()!="")
					{
					model.credit=dt.Rows[n]["credit"].ToString();
					}
					if(dt.Rows[n]["link1"]!=null && dt.Rows[n]["link1"].ToString()!="")
					{
					model.link1=dt.Rows[n]["link1"].ToString();
					}
					if(dt.Rows[n]["dept1"]!=null && dt.Rows[n]["dept1"].ToString()!="")
					{
					model.dept1=dt.Rows[n]["dept1"].ToString();
					}
					if(dt.Rows[n]["job1"]!=null && dt.Rows[n]["job1"].ToString()!="")
					{
					model.job1=dt.Rows[n]["job1"].ToString();
					}
					if(dt.Rows[n]["tel1"]!=null && dt.Rows[n]["tel1"].ToString()!="")
					{
					model.tel1=dt.Rows[n]["tel1"].ToString();
					}
					if(dt.Rows[n]["phone1"]!=null && dt.Rows[n]["phone1"].ToString()!="")
					{
					model.phone1=dt.Rows[n]["phone1"].ToString();
					}
					if(dt.Rows[n]["link2"]!=null && dt.Rows[n]["link2"].ToString()!="")
					{
					model.link2=dt.Rows[n]["link2"].ToString();
					}
					if(dt.Rows[n]["dept2"]!=null && dt.Rows[n]["dept2"].ToString()!="")
					{
					model.dept2=dt.Rows[n]["dept2"].ToString();
					}
					if(dt.Rows[n]["job2"]!=null && dt.Rows[n]["job2"].ToString()!="")
					{
					model.job2=dt.Rows[n]["job2"].ToString();
					}
					if(dt.Rows[n]["tel2"]!=null && dt.Rows[n]["tel2"].ToString()!="")
					{
					model.tel2=dt.Rows[n]["tel2"].ToString();
					}
					if(dt.Rows[n]["phone2"]!=null && dt.Rows[n]["phone2"].ToString()!="")
					{
					model.phone2=dt.Rows[n]["phone2"].ToString();
					}
					if(dt.Rows[n]["mapImg"]!=null && dt.Rows[n]["mapImg"].ToString()!="")
					{
						model.mapImg=(byte[])dt.Rows[n]["mapImg"];
					}
					if(dt.Rows[n]["drive"]!=null && dt.Rows[n]["drive"].ToString()!="")
					{
					model.drive=dt.Rows[n]["drive"].ToString();
					}
					if(dt.Rows[n]["bus"]!=null && dt.Rows[n]["bus"].ToString()!="")
					{
					model.bus=dt.Rows[n]["bus"].ToString();
					}
					if(dt.Rows[n]["createDate"]!=null && dt.Rows[n]["createDate"].ToString()!="")
					{
						model.createDate=DateTime.Parse(dt.Rows[n]["createDate"].ToString());
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}
Example #8
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <CustomerService.Model.Customer> DataTableToList(DataTable dt)
        {
            List <CustomerService.Model.Customer> modelList = new List <CustomerService.Model.Customer>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                CustomerService.Model.Customer model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new CustomerService.Model.Customer();
                    if (dt.Rows[n]["GUID"] != null && dt.Rows[n]["GUID"].ToString() != "")
                    {
                        model.GUID = new Guid(dt.Rows[n]["GUID"].ToString());
                    }
                    if (dt.Rows[n]["cNO"] != null && dt.Rows[n]["cNO"].ToString() != "")
                    {
                        model.cNO = dt.Rows[n]["cNO"].ToString();
                    }
                    if (dt.Rows[n]["parentGUID"] != null && dt.Rows[n]["parentGUID"].ToString() != "")
                    {
                        model.parentGUID = new Guid(dt.Rows[n]["parentGUID"].ToString());
                    }
                    if (dt.Rows[n]["cName"] != null && dt.Rows[n]["cName"].ToString() != "")
                    {
                        model.cName = dt.Rows[n]["cName"].ToString();
                    }
                    if (dt.Rows[n]["cMan"] != null && dt.Rows[n]["cMan"].ToString() != "")
                    {
                        model.cMan = dt.Rows[n]["cMan"].ToString();
                    }
                    if (dt.Rows[n]["Tel"] != null && dt.Rows[n]["Tel"].ToString() != "")
                    {
                        model.Tel = dt.Rows[n]["Tel"].ToString();
                    }
                    if (dt.Rows[n]["isGov"] != null && dt.Rows[n]["isGov"].ToString() != "")
                    {
                        if ((dt.Rows[n]["isGov"].ToString() == "1") || (dt.Rows[n]["isGov"].ToString().ToLower() == "true"))
                        {
                            model.isGov = true;
                        }
                        else
                        {
                            model.isGov = false;
                        }
                    }
                    if (dt.Rows[n]["trade"] != null && dt.Rows[n]["trade"].ToString() != "")
                    {
                        model.trade = dt.Rows[n]["trade"].ToString();
                    }
                    if (dt.Rows[n]["deptUp"] != null && dt.Rows[n]["deptUp"].ToString() != "")
                    {
                        model.deptUp = dt.Rows[n]["deptUp"].ToString();
                    }
                    if (dt.Rows[n]["cType"] != null && dt.Rows[n]["cType"].ToString() != "")
                    {
                        model.cType = dt.Rows[n]["cType"].ToString();
                    }
                    if (dt.Rows[n]["cStage"] != null && dt.Rows[n]["cStage"].ToString() != "")
                    {
                        model.cStage = dt.Rows[n]["cStage"].ToString();
                    }
                    if (dt.Rows[n]["cStatus"] != null && dt.Rows[n]["cStatus"].ToString() != "")
                    {
                        model.cStatus = dt.Rows[n]["cStatus"].ToString();
                    }
                    if (dt.Rows[n]["cLevel"] != null && dt.Rows[n]["cLevel"].ToString() != "")
                    {
                        model.cLevel = dt.Rows[n]["cLevel"].ToString();
                    }
                    if (dt.Rows[n]["province"] != null && dt.Rows[n]["province"].ToString() != "")
                    {
                        model.province = dt.Rows[n]["province"].ToString();
                    }
                    if (dt.Rows[n]["city"] != null && dt.Rows[n]["city"].ToString() != "")
                    {
                        model.city = dt.Rows[n]["city"].ToString();
                    }
                    if (dt.Rows[n]["district"] != null && dt.Rows[n]["district"].ToString() != "")
                    {
                        model.district = dt.Rows[n]["district"].ToString();
                    }
                    if (dt.Rows[n]["fax"] != null && dt.Rows[n]["fax"].ToString() != "")
                    {
                        model.fax = dt.Rows[n]["fax"].ToString();
                    }
                    if (dt.Rows[n]["addresss"] != null && dt.Rows[n]["addresss"].ToString() != "")
                    {
                        model.addresss = dt.Rows[n]["addresss"].ToString();
                    }
                    if (dt.Rows[n]["zip"] != null && dt.Rows[n]["zip"].ToString() != "")
                    {
                        model.zip = dt.Rows[n]["zip"].ToString();
                    }
                    if (dt.Rows[n]["netSet"] != null && dt.Rows[n]["netSet"].ToString() != "")
                    {
                        model.netSet = dt.Rows[n]["netSet"].ToString();
                    }
                    if (dt.Rows[n]["email"] != null && dt.Rows[n]["email"].ToString() != "")
                    {
                        model.email = dt.Rows[n]["email"].ToString();
                    }
                    if (dt.Rows[n]["QQ"] != null && dt.Rows[n]["QQ"].ToString() != "")
                    {
                        model.QQ = dt.Rows[n]["QQ"].ToString();
                    }
                    if (dt.Rows[n]["mode"] != null && dt.Rows[n]["mode"].ToString() != "")
                    {
                        model.mode = dt.Rows[n]["mode"].ToString();
                    }
                    if (dt.Rows[n]["scope"] != null && dt.Rows[n]["scope"].ToString() != "")
                    {
                        model.scope = dt.Rows[n]["scope"].ToString();
                    }
                    if (dt.Rows[n]["product"] != null && dt.Rows[n]["product"].ToString() != "")
                    {
                        model.product = dt.Rows[n]["product"].ToString();
                    }
                    if (dt.Rows[n]["opponent"] != null && dt.Rows[n]["opponent"].ToString() != "")
                    {
                        model.opponent = dt.Rows[n]["opponent"].ToString();
                    }
                    if (dt.Rows[n]["credit"] != null && dt.Rows[n]["credit"].ToString() != "")
                    {
                        model.credit = dt.Rows[n]["credit"].ToString();
                    }
                    if (dt.Rows[n]["link1"] != null && dt.Rows[n]["link1"].ToString() != "")
                    {
                        model.link1 = dt.Rows[n]["link1"].ToString();
                    }
                    if (dt.Rows[n]["dept1"] != null && dt.Rows[n]["dept1"].ToString() != "")
                    {
                        model.dept1 = dt.Rows[n]["dept1"].ToString();
                    }
                    if (dt.Rows[n]["job1"] != null && dt.Rows[n]["job1"].ToString() != "")
                    {
                        model.job1 = dt.Rows[n]["job1"].ToString();
                    }
                    if (dt.Rows[n]["tel1"] != null && dt.Rows[n]["tel1"].ToString() != "")
                    {
                        model.tel1 = dt.Rows[n]["tel1"].ToString();
                    }
                    if (dt.Rows[n]["phone1"] != null && dt.Rows[n]["phone1"].ToString() != "")
                    {
                        model.phone1 = dt.Rows[n]["phone1"].ToString();
                    }
                    if (dt.Rows[n]["link2"] != null && dt.Rows[n]["link2"].ToString() != "")
                    {
                        model.link2 = dt.Rows[n]["link2"].ToString();
                    }
                    if (dt.Rows[n]["dept2"] != null && dt.Rows[n]["dept2"].ToString() != "")
                    {
                        model.dept2 = dt.Rows[n]["dept2"].ToString();
                    }
                    if (dt.Rows[n]["job2"] != null && dt.Rows[n]["job2"].ToString() != "")
                    {
                        model.job2 = dt.Rows[n]["job2"].ToString();
                    }
                    if (dt.Rows[n]["tel2"] != null && dt.Rows[n]["tel2"].ToString() != "")
                    {
                        model.tel2 = dt.Rows[n]["tel2"].ToString();
                    }
                    if (dt.Rows[n]["phone2"] != null && dt.Rows[n]["phone2"].ToString() != "")
                    {
                        model.phone2 = dt.Rows[n]["phone2"].ToString();
                    }
                    if (dt.Rows[n]["mapImg"] != null && dt.Rows[n]["mapImg"].ToString() != "")
                    {
                        model.mapImg = (byte[])dt.Rows[n]["mapImg"];
                    }
                    if (dt.Rows[n]["drive"] != null && dt.Rows[n]["drive"].ToString() != "")
                    {
                        model.drive = dt.Rows[n]["drive"].ToString();
                    }
                    if (dt.Rows[n]["bus"] != null && dt.Rows[n]["bus"].ToString() != "")
                    {
                        model.bus = dt.Rows[n]["bus"].ToString();
                    }
                    if (dt.Rows[n]["createDate"] != null && dt.Rows[n]["createDate"].ToString() != "")
                    {
                        model.createDate = DateTime.Parse(dt.Rows[n]["createDate"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Example #9
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(CustomerService.Model.Customer model)
 {
     return(dal.Update(model));
 }
Example #10
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(CustomerService.Model.Customer model)
 {
     return(dal.Add(model));
 }