private void skinLabelAddSupplier_Click(object sender, EventArgs e) { try { if (GlobalUtil.EngineUnconnectioned(this)) { return; } List <PfCustomer> list = (List <PfCustomer>) this.skinComboBox_PfCustomer.DataSource; NewWholesaleCustomerSimpleForm addForm = new NewWholesaleCustomerSimpleForm(); if (addForm.ShowDialog(this) == DialogResult.OK) { if (list == null) { list = new List <PfCustomer>(); } PfCustomer item = addForm.Result; PfCustomer listItem = list.Find(t => t.Name == item.Name || t.ID == item.ID); if (listItem == null) { item.Enabled = true; item.CreateTime = DateTime.Now; InteractResult result = PfCustomerCache.PfCustomer_OnInsert(item); switch (result.ExeResult) { case ExeResult.Success: this.skinComboBox_PfCustomer.DataSource = null; list.Add(item); this.skinComboBox_PfCustomer.DisplayMember = "Name"; this.skinComboBox_PfCustomer.ValueMember = "ID"; this.skinComboBox_PfCustomer.DataSource = list; // this.skinComboBox_SupplierID.SelectedIndex = list.IndexOf(item); break; case ExeResult.Error: break; default: break; } } else { // this.skinComboBox_SupplierID.SelectedItem = listItem; } } } catch (Exception ex) { GlobalUtil.ShowError(ex); } finally { GlobalUtil.UnLockPage(this); } }
private void Btn_Save_Click(object sender, EventArgs e) { try { if (GlobalUtil.EngineUnconnectioned(this)) { return; } //ShowMessage(Pinyin.GetInitials("埼", Encoding.GetEncoding("GB2312"))); if (curPfCustomer == null) { String name = this.skinTextBox_Name.SkinTxt.Text.Trim(); PfCustomer pfCustomer = new PfCustomer() { ID = this.skinTextBox_ID.SkinTxt.Text.Trim(), Name = name, Contact = this.skinTextBox_Contact.SkinTxt.Text.Trim(), ContactPhone = this.skinTextBox_ContactPhone.SkinTxt.Text.Trim(), BankInfo = this.skinTextBox_BankInfo.SkinTxt.Text.Trim(), Remarks = this.skinTextBox_Remarks.SkinTxt.Text.Trim(), PfDiscount = this.textBoxDicount.Value, BusinessAccountID = textBoxBusinessAccount.Text.Trim(), Password = this.textBoxPwd.Text.Trim(), LastAccountTime = DateTime.Now, DefaultAddressID = 0, Balance = 0, PaymentBalance = 0, FirstCharSpell = DisplayUtil.GetPYString(name), // SupplyDiscount = Decimal.ToByte(this.numericUpDownSupplyDiscount.Value), Enabled = this.skinCheckBox_Enabled.Checked, CreateTime = DateTime.Now, CustomerType = (byte)(skinRadioButtonSale.Checked ? 1 : 0) }; if (String.IsNullOrEmpty(pfCustomer.ID)) { GlobalMessageBox.Show("客户编号不能为空,请输入编号!"); this.skinTextBox_ID.Focus(); return; } else if (String.IsNullOrEmpty(pfCustomer.Name)) { GlobalMessageBox.Show("客户名称不能为空,请输入名称!"); this.skinTextBox_Name.Focus(); return; } else if (String.IsNullOrEmpty(pfCustomer.Password)) { GlobalMessageBox.Show("客户密码不能为空,请输入密码!"); this.textBoxPwd.Focus(); return; } //BusinessAccountID 账套不能为当前账套 string CurrbusinessAccountId = CommonGlobalCache.BusinessAccount.ID.ToUpper(); if (pfCustomer.BusinessAccountID.ToUpper() == CurrbusinessAccountId) { GlobalMessageBox.Show("不能绑定当前账套!"); this.textBoxBusinessAccount.Focus(); return; } InteractResult result = PfCustomerCache.PfCustomer_OnInsert(pfCustomer); switch (result.ExeResult) { case ExeResult.Success: TreeModel treeN = new TreeModel(); treeN.ID = pfCustomer.ID; treeN.Name = pfCustomer.Name; CommonGlobalCache.InsertPFDistributor(treeN); //CommonGlobalCache.DistributorPFList.Clear(); GlobalMessageBox.Show("添加成功!"); TabPage_Close(this.CurrentTabPage, this.SourceCtrlType); break; case ExeResult.Error: GlobalMessageBox.Show(result.Msg); break; default: break; } } else { this.curPfCustomer.ID = this.skinTextBox_ID.SkinTxt.Text.Trim(); this.curPfCustomer.Name = this.skinTextBox_Name.SkinTxt.Text.Trim(); this.curPfCustomer.Contact = this.skinTextBox_Contact.SkinTxt.Text.Trim(); this.curPfCustomer.ContactPhone = this.skinTextBox_ContactPhone.SkinTxt.Text.Trim(); this.curPfCustomer.BankInfo = this.skinTextBox_BankInfo.SkinTxt.Text.Trim(); this.curPfCustomer.Remarks = this.skinTextBox_Remarks.SkinTxt.Text.Trim(); this.curPfCustomer.PfDiscount = this.textBoxDicount.Value; this.curPfCustomer.BusinessAccountID = this.textBoxBusinessAccount.Text.Trim(); this.curPfCustomer.Password = this.textBoxPwd.Text; this.curPfCustomer.Enabled = this.skinCheckBox_Enabled.Checked; this.curPfCustomer.FirstCharSpell = DisplayUtil.GetPYString(this.curPfCustomer.Name); this.curPfCustomer.CustomerType = (byte)(skinRadioButtonSale.Checked ? 1 : 0); if (String.IsNullOrEmpty(curPfCustomer.Password)) { this.textBoxPwd.Focus(); return; } //BusinessAccountID 账套不能为当前账套 string CurrbusinessAccountId = CommonGlobalCache.BusinessAccount.ID.ToUpper(); if (curPfCustomer.BusinessAccountID.ToUpper() == CurrbusinessAccountId) { this.textBoxBusinessAccount.Focus(); GlobalMessageBox.Show("不能绑定当前账套!"); return; } InteractResult result = PfCustomerCache.PfCustomer_OnUpdate(curPfCustomer); switch (result.ExeResult) { case ExeResult.Error: GlobalMessageBox.Show(result.Msg); break; default: TreeModel treeN = new TreeModel(); treeN.ID = curPfCustomer.ID; treeN.Name = curPfCustomer.Name; CommonGlobalCache.UpdatePFDistributor(treeN); GlobalMessageBox.Show("保存成功!"); SaveResult?.Invoke(curPfCustomer); TabPage_Close(this.CurrentTabPage, this.SourceCtrlType); break; } } } catch (Exception ex) { GlobalUtil.ShowError(ex); } finally { GlobalUtil.UnLockPage(this); } }
private void BaseButton1_Click(object sender, EventArgs e) { try { if (GlobalUtil.EngineUnconnectioned(this)) { return; } PfCustomer pfCustomer = Build(); if (!ValidateItem(pfCustomer)) { return; } if (curPfCustomer == null) { InteractResult result = PfCustomerCache.PfCustomer_OnInsert(pfCustomer); switch (result.ExeResult) { case ExeResult.Success: GlobalMessageBox.Show("添加成功!"); if (node != null) { TreeModel CurChildrenClass = new TreeModel(); TreeNode newNode = new TreeNode(pfCustomer.Name); CurChildrenClass.Name = pfCustomer.Name; CurChildrenClass.ID = pfCustomer.ID; CurChildrenClass.ParentID = curItemID; newNode.Tag = CurChildrenClass; newNode.Text = pfCustomer.Name + "/" + pfCustomer.ContactPhone + "(0.00)"; node.Nodes.Add(newNode); CommonGlobalCache.InsertPFDistributor(CurChildrenClass); } ConfirmClick?.Invoke(curPfCustomer, this); this.Close(); break; case ExeResult.Error: GlobalMessageBox.Show(result.Msg); break; default: break; } } else { pfCustomer.CreateTime = curPfCustomer.CreateTime; InteractResult result = PfCustomerCache.PfCustomer_OnUpdate(pfCustomer); switch (result.ExeResult) { case ExeResult.Error: GlobalMessageBox.Show(result.Msg); break; default: GlobalMessageBox.Show("保存成功!"); this.DialogResult = DialogResult.OK; if (node != null) { List <TreeModel> treeModelL = CommonGlobalCache.DistributorPFList.FindAll(t => t.ID == pfCustomer.ID); TreeModel bigClass = node.Tag as TreeModel; bigClass.ID = pfCustomer.ID; bigClass.Name = pfCustomer.Name; bigClass.AccruedCommission = curPfCustomer.AccruedCommission; string accruedC = "0.00"; if (treeModelL.Count > 0) { accruedC = treeModelL[0].AccruedCommission.ToString(); } //JGNet.Common.ServerProxy.GetPfCustomer InteractResult <PfCustomer> selectPfCus = CommonGlobalCache.ServerProxy.GetPfCustomer(pfCustomer.ID); if (selectPfCus != null) { accruedC = Math.Round(selectPfCus.Data.AccruedCommission, 2).ToString(); } node.Text = pfCustomer.Name + "/" + pfCustomer.ContactPhone + "(" + accruedC + ")"; node.Tag = bigClass; CommonGlobalCache.UpdatePFDistributor(bigClass); } this.curPfCustomer = pfCustomer; ConfirmClick?.Invoke(curPfCustomer, this); this.Close(); break; } } } catch (Exception ex) { GlobalUtil.ShowError(ex); } finally { GlobalUtil.UnLockPage(this); } }