private void UpdatePayType(int selectType, PfInfo item) { switch (selectType) { case 0: //记录一条欠条 GlobalCache.ServerProxy.PfDelivery(item); break; case 1: //减去余额 pfCustomer.Balance -= item.PfOrder.TotalPfPrice; InteractResult interactResult = PfCustomerCache.PfCustomer_OnUpdate(pfCustomer); switch (interactResult.ExeResult) { case ExeResult.Success: break; case ExeResult.Error: GlobalMessageBox.Show(interactResult.Msg); break; default: break; } break; case 2: break; default: break; } }
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); } }