Example #1
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            for (int i = 0; i < frmMain.Main.DockPanelMain.Contents.Count; i++)
            {
                if (frmMain.Main.DockPanelMain.Contents[i] is dockCustomer)
                {
                    dockCustomer dc =
                        (dockCustomer)frmMain.Main.DockPanelMain.Contents[i];
                    if (dc.GUID.ToString() == e.Node.Name)
                    {
                        if (!(dc.GUID == Guid.Empty) &&
                            dc.TabText.Substring(5) !=
                            e.Node.Text)
                        {
                            string str = "客户信息-";
                            dc.TabText = str + e.Node.Text;
                        }

                        dc.Focus();
                        dc.GetData();
                        return;
                    }
                }
            }

            dockCustomer dock = new dockCustomer();

            if (!(e.Node.Name == Guid.Empty.ToString()))
            {
                dock.TabText += "-" + e.Node.Text;
            }
            dock.GUID = new Guid(e.Node.Name);
            dock.Show(frmMain.Main.DockPanelMain);
        }
Example #2
0
        private void tsbCustomer_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < this.dockPanel1.Contents.Count; i++)
            {
                if (frmMain.Main.DockPanelMain.Contents[i] is dockCustomer)
                {
                    dockCustomer dc =
                        (dockCustomer)this.dockPanel1.Contents[i];
                    if (dc.GUID.ToString() == Guid.Empty.ToString())
                    {
                        dc.Focus();
                        dc.GetData();
                        return;
                    }
                }
            }

            dockCustomer dock = new dockCustomer();

            dock.Show(this.dockPanel1);
        }
Example #3
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();
                }
            }
        }