private PfCustomer Build() { PfCustomer customer = new PfCustomer(); customer.ID = this.skinTextBoxID.SkinTxt.Text.Trim(); customer.FirstCharSpell = DisplayUtil.GetPYString(this.skinTextBoxName.SkinTxt.Text.Trim()); customer.Name = this.skinTextBoxName.SkinTxt.Text.Trim(); customer.Contact = this.skinTextBox_Contact.SkinTxt.Text.Trim(); customer.ContactPhone = this.skinTextBox_ContactPhone.SkinTxt.Text.Trim(); customer.BankInfo = this.skinTextBox_BankInfo.SkinTxt.Text.Trim(); customer.Remarks = this.skinTextBox_Remarks.SkinTxt.Text.Trim(); customer.PfDiscount = this.skinTextBox_Percent.Value; customer.BusinessAccountID = textBoxBusinessAccount.Text.Trim(); customer.Password = this.textBoxPwd.Text.Trim(); customer.LastAccountTime = DateTime.Now; customer.DefaultAddressID = 0; customer.Balance = 0; customer.PaymentBalance = 0; if (node.Text != "所有分销客户") { customer.DistributorID = curItemID; } // SupplyDiscount = Decimal.ToByte(this.numericUpDownSupplyDiscount.Value), customer.Enabled = this.skinCheckBox_Enabled.Checked; customer.CreateTime = DateTime.Now; customer.CustomerType = (byte)(skinRadioButtonSale.Checked ? 1 : 0); return(customer); }
private void SkinTxt_TextChanged(object sender, EventArgs e) { if (String.IsNullOrEmpty(skinTextBoxCode.Text)) { skinTextBoxCode.Text = DisplayUtil.GetPYString(skinTextBoxID.Text); } }
private void BaseButton1_Click(object sender, EventArgs e) { try { string brandName = skinTextBoxID.SkinTxt.Text; if (string.IsNullOrEmpty(brandName)) { MessageBox.Show("名称不能为空!"); this.skinTextBoxID.Focus(); return; } if (action == OperationEnum.Edit) { item.Name = brandName; item.FirstCharSpell = DisplayUtil.GetPYString(item.Name); item.OrderNo = Decimal.ToInt32(textBoxSort.Value); item.IsDisable = !skinCheckBoxEnable.Checked; if (GlobalCache.BrandList.Exists(t => t.Name == item.Name && t.AutoID != item.AutoID)) { GlobalMessageBox.Show("品牌已存在!"); return; } } else { this.item = new Brand() { Name = brandName, OrderNo = Decimal.ToInt32(textBoxSort.Value), FirstCharSpell = DisplayUtil.GetPYString(brandName), IsDisable = !skinCheckBoxEnable.Checked, }; if (GlobalCache.BrandList.Exists(t => t.Name == item.Name)) { GlobalMessageBox.Show("品牌已存在!"); return; } } this.DialogResult = DialogResult.OK; } catch (Exception ex) { GlobalUtil.ShowError(ex); } finally { GlobalUtil.UnLockPage(this); } }
private void BaseButton1_Click(object sender, EventArgs e) { String id = this.skinTextBoxID.SkinTxt.Text.Trim(); String name = this.skinTextBoxName.SkinTxt.Text.Trim(); String pwd = this.textBoxPwd.SkinTxt.Text.Trim(); if (String.IsNullOrEmpty(id)) { this.skinTextBoxID.Focus(); return; } else if (String.IsNullOrEmpty(name)) { this.skinTextBoxName.Focus(); return; } else if (String.IsNullOrEmpty(pwd)) { this.textBoxPwd.Focus(); return; } byte customerType = 0; if (skinRadioButtonSale.Checked) { customerType = 1; } else if (skinRadioButtonBuyout.Checked) { customerType = 0; } //skinRadioButtonBuyout.Checked = this.curPfCustomer.CustomerType == 0; decimal pfDiscount = this.textBoxDicount.Value; this.result = new PfCustomer() { ID = id, Name = name, Password = pwd, FirstCharSpell = DisplayUtil.GetPYString(name), CustomerType = customerType, PfDiscount = pfDiscount, // SupplyDiscount = Decimal.ToByte(numericUpDownSupplyDiscount.Value) }; this.DialogResult = DialogResult.OK; }
public void Initialize(bool hideAll, bool isEnableList, int customerTypeValue = -1) { this.hideAll = hideAll; this.isEnableList = isEnableList; CustomerTypeValue = customerTypeValue; List <PfCustomer> list = new List <PfCustomer>(); if (!hideAll) { list.Add(new PfCustomer() { Name = CommonGlobalUtil.COMBOBOX_ALL, FirstCharSpell = DisplayUtil.GetPYString(CommonGlobalUtil.COMBOBOX_ALL), ID = null }); } List <PfCustomer> pfCustomerList = PfCustomerCache.PfCustomerList; if (pfCustomerList != null && CustomerTypeValue != -1) { pfCustomerList = pfCustomerList.FindAll(t => t.CustomerType == CustomerTypeValue); } if (isEnableList) { List <PfCustomer> pfs = pfCustomerList?.FindAll(t => t.Enabled); if (pfs != null) { list.AddRange(pfs); } } else { List <PfCustomer> pfs = pfCustomerList; if (pfs != null) { list.AddRange(pfs); } } DisplayMember = "Name"; ValueMember = "ID"; DataSource = list; }
public static void Load() { if (pfCustomerList == null) { GetPfCustomerPagePara pfPara = new GetPfCustomerPagePara() { PageIndex = 0, PageSize = int.MaxValue }; pfCustomerList = PfCustomerCache.ServerProxy.GetPfCustomerPage(pfPara)?.PfCustomers; if (pfCustomerList != null && pfCustomerList.Count > 0) { foreach (var item in pfCustomerList) { if (string.IsNullOrEmpty(item.FirstCharSpell)) { item.FirstCharSpell = DisplayUtil.GetPYString(item.Name); } } } } }
private void BaseButton1_Click(object sender, EventArgs e) { String id = this.skinTextBoxID.SkinTxt.Text.Trim(); String name = this.skinTextBoxName.SkinTxt.Text.Trim(); if (String.IsNullOrEmpty(id) || !ValidateUtil.CheckMoney(id)) { this.skinTextBoxID.Focus(); return; } else if (String.IsNullOrEmpty(name)) { this.skinTextBoxName.Focus(); return; } this.result = new CostumeColor() { ID = id, Name = name, FirstCharSpell = DisplayUtil.GetPYString(name) // SupplyDiscount = Decimal.ToByte(numericUpDownSupplyDiscount.Value) }; this.DialogResult = DialogResult.OK; }
private void skinComboBox_TextUpdate(object sender, EventArgs e) { try { List <PfCustomer> listNew = new List <PfCustomer>(); // skinComboBox_Brand.Items.Clear(); SkinComboBox box = (SkinComboBox)sender; List <PfCustomer> temp = (List <PfCustomer>)box.DataSource; if (temp != null && temp.Count == 0) { List <PfCustomer> tempList = new List <PfCustomer>(); tempList[0].ID = null; tempList[0].Name = null; box.DisplayMember = "Name"; box.ValueMember = "ID"; box.DataSource = tempList; return; } String str = box.Text; curSelectStr = str; List <PfCustomer> pfCustomerList = PfCustomerCache.PfCustomerList; if (pfCustomerList != null && CustomerTypeValue != -1) { pfCustomerList = pfCustomerList.FindAll(t => t.CustomerType == CustomerTypeValue); } if (String.IsNullOrEmpty(str)) { if (!hideAll) { listNew.Add(new PfCustomer() { Name = CommonGlobalUtil.COMBOBOX_ALL, FirstCharSpell = DisplayUtil.GetPYString(CommonGlobalUtil.COMBOBOX_ALL), ID = null }); } if (isEnableList) { listNew.AddRange(pfCustomerList?.FindAll(t => t.Enabled)); } else { listNew.AddRange(pfCustomerList); } } else { if (!hideAll) { listNew.Add(new PfCustomer() { Name = CommonGlobalUtil.COMBOBOX_ALL, FirstCharSpell = DisplayUtil.GetPYString(CommonGlobalUtil.COMBOBOX_ALL), ID = null }); } List <PfCustomer> list = new List <PfCustomer>(); if (isEnableList) { list.AddRange(pfCustomerList?.FindAll(t => t.Enabled)); } else { list.AddRange(pfCustomerList); } foreach (var item in list) { if ((item.FirstCharSpell).ToUpper().Contains(str.ToUpper()) || (item.ID).ToUpper().Contains(str.ToUpper()) || (item.Name).ToUpper().Contains(str.ToUpper())) { listNew.Add(item); } } } if (listNew.Count == 0) { if (!HideEmpty) { listNew.Add(new PfCustomer() { ID = null, Name = "(无)", FirstCharSpell = DisplayUtil.GetPYString("(无)") }); } } //box.DataSource = null; if (isEnableList) { listNew = listNew.FindAll(t => t.Enabled); } if (listNew == null || listNew.Count == 0) { List <PfCustomer> tempList = new List <PfCustomer>(); PfCustomer firstPC = new PfCustomer(); firstPC.ID = null; firstPC.Name = null; tempList.Add(firstPC); box.DisplayMember = "Name"; box.ValueMember = "ID"; box.DataSource = tempList; } else { List <PfCustomer> PfList = new List <PfCustomer>(); if (!hideAll && this.Text == "") { PfList.Add(new PfCustomer() { Name = CommonGlobalUtil.COMBOBOX_ALL, FirstCharSpell = DisplayUtil.GetPYString(CommonGlobalUtil.COMBOBOX_ALL), ID = null }); } PfList.AddRange(listNew); box.DisplayMember = "Name"; box.ValueMember = "ID"; box.DataSource = PfList; } box.DroppedDown = true;//自动展开下拉框 box.Text = str; curSelectStr = str; //box.sele = str; box.Select(box.Text.Length, 0); //滚动到控件光标处 // box.ScrollToCaret(); //box.SelectionStart = str.Length; // box.Cursor = Cursors.Default; System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default; box.Cursor = System.Windows.Forms.Cursors.Default; } catch (Exception ex) { // CommonGlobalUtil.ShowError(ex); } }
private void DoImport() { try { List <CostumeColor> emptyStore = new List <CostumeColor>(); List <CostumeColor> stores = new List <CostumeColor>(); List <CostumeColor> repeatItems = new List <CostumeColor>(); DataTable dt = NPOIHelper.FormatToDatatable(path, 0); for (int i = 1; i < dt.Rows.Count; i++) { DataRow row = dt.Rows[i]; int index = 0; CostumeColor store = new CostumeColor(); try { if (!CommonGlobalUtil.ImportValidate(row, 2)) { store.AutoCode = (i + 2); store.Name = CommonGlobalUtil.ConvertToString(row[index++]); store.ID = CommonGlobalUtil.ConvertToString(row[index++]); store.FirstCharSpell = DisplayUtil.GetPYString(store.Name); if (String.IsNullOrEmpty(store.Name)) { //必填项为空 emptyStore.Add(store); continue; } else { //判断是否重复款号/颜色 if (stores.Find(t => t.Name == store.Name) != null) { repeatItems.Add(store); continue; } stores.Add(store); } } } catch (Exception ex) { } } if (emptyStore.Count > 0) { String str = string.Empty; foreach (var item in emptyStore) { str += "第" + item.AutoCode + "行\r\n"; } ShowError("必填项没有填写,请补充完整!\r\n" + str); return; } if (repeatItems.Count > 0) { String str = string.Empty; foreach (var item in repeatItems) { str += "第" + item.AutoCode + "行" + "\r\n"; } ShowError("名称重复,系统已过滤,详见错误报告!\r\n" + str); // return; } if (stores != null && stores.Count > 0) { } else { ShowMessage("没有数据可以导入,请检查列表信息!"); return; } path = null; //檢查結果 InteractResult result = GlobalCache.ServerProxy.ImportCostumeColors(stores); switch (result.ExeResult) { case ExeResult.Error: GlobalMessageBox.Show(result.Msg); break; case ExeResult.Success: RefreshPage(); ShowMessage("导入成功!"); break; default: break; } } catch (Exception ex) { ShowError(ex); } finally { UnLockPage(); } }
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 { string name = skinTextBoxName.Text; string id = skinTextBoxID.Text; List <CostumeColor> costumeColor = GlobalCache.CostumeColorList; if (string.IsNullOrEmpty(id)) { GlobalMessageBox.Show("色号不能为空!"); this.skinTextBoxID.Focus(); return; } else if (string.IsNullOrEmpty(name)) { GlobalMessageBox.Show("名称不能为空!"); this.skinTextBoxName.Focus(); return; } else { if (this.color != null) { //编辑的时候,判断是否有重复ID。排除自己 List <CostumeColor> colorChecked = costumeColor.FindAll(t => t.ID == id); if (colorChecked != null && colorChecked.Count > 1) { GlobalMessageBox.Show("该色号已存在!"); this.skinTextBoxID.Focus(); return; } } else { CostumeColor colorChecked = costumeColor.Find(t => t.ID == id); if (colorChecked != null) { GlobalMessageBox.Show("该色号已存在!"); this.skinTextBoxID.Focus(); return; } } if (this.color != null) { //编辑的时候,判断是否有重复ID。排除自己 List <CostumeColor> colorChecked = costumeColor.FindAll(t => t.Name == name); if (colorChecked != null && colorChecked.Count > 1) { GlobalMessageBox.Show("名称已存在!"); this.skinTextBoxName.Focus(); return; } } else { CostumeColor colorChecked = costumeColor.Find(t => t.Name == name); if (colorChecked != null) { GlobalMessageBox.Show("名称已存在!"); this.skinTextBoxName.Focus(); return; } } } if (action == OperationEnum.Edit) { color.ID = id; color.Name = name; color.FirstCharSpell = DisplayUtil.GetPYString(name); } else { this.color = new CostumeColor() { ID = id, Name = name, FirstCharSpell = DisplayUtil.GetPYString(name), }; } this.DialogResult = DialogResult.OK; } catch (Exception ex) { GlobalUtil.ShowError(ex); } finally { GlobalUtil.UnLockPage(this); } }
private void DoImport() { try { List <PfCustomer> emptyStore = new List <PfCustomer>(); List <PfCustomer> stores = new List <PfCustomer>(); List <PfCustomer> repeatItems = new List <PfCustomer>(); DataTable dt = NPOIHelper.FormatToDatatable(path, 0); for (int i = 1; i < dt.Rows.Count; i++) { DataRow row = dt.Rows[i]; int index = 0; PfCustomer store = new PfCustomer(); try { if (!CommonGlobalUtil.ImportValidate(row, 10)) { // 名称 进货折扣 联系人 联系电话 银行账户信息 应付款结余(正数表示欠供应商) 最后一次记账时间 创建时间 序号 备注 store.ID = "" + (i + 2); store.Name = CommonGlobalUtil.ConvertToString(row[index++]); store.PfDiscount = CommonGlobalUtil.ConvertToDecimal(row[index++]); store.Contact = CommonGlobalUtil.ConvertToString(row[index++]); store.ContactPhone = CommonGlobalUtil.ConvertToString(row[index++]); store.BankInfo = CommonGlobalUtil.ConvertToString(row[index++]); store.PaymentBalance = CommonGlobalUtil.ConvertToDecimal(row[index++]); store.LastAccountTime = DateTimeUtil.ConvertToDateTime(CommonGlobalUtil.ConvertToString(row[index++])); store.Balance = CommonGlobalUtil.ConvertToDecimal(CommonGlobalUtil.ConvertToString(row[index++])); store.CreateTime = DateTimeUtil.ConvertToDateTime(CommonGlobalUtil.ConvertToString(row[index++])); store.Remarks = CommonGlobalUtil.ConvertToString(row[index++]); store.FirstCharSpell = DisplayUtil.GetPYString(store.Name); int tempindex = index++; store.CustomerType = (byte)CommonGlobalUtil.ConvertToInt16(row[tempindex]); if (String.IsNullOrEmpty(store.Name) || String.IsNullOrEmpty(row[tempindex].ToString())) { //必填项为空 emptyStore.Add(store); continue; } else { //判断是否重复款号/颜色 if (stores.Find(t => t.Name == store.Name) != null) { repeatItems.Add(store); continue; } stores.Add(store); } } } catch (Exception ex) { } } if (emptyStore.Count > 0) { String str = string.Empty; foreach (var item in emptyStore) { str += "第" + item.ID + "行\r\n"; } ShowError("必填项没有填写,请补充完整!\r\n" + str); return; } if (repeatItems.Count > 0) { String str = string.Empty; foreach (var item in repeatItems) { str += "第" + item.ID + "行" + "\r\n"; } ShowError("名称重复,系统已过滤,详见错误报告!\r\n" + str); // return; } if (stores != null && stores.Count > 0) { } else { ShowMessage("没有数据可以导入,请检查列表信息!"); return; } path = null; //檢查結果 InteractResult result = GlobalCache.ServerProxy.ImportPfCustomer(stores); switch (result.ExeResult) { case ExeResult.Error: GlobalMessageBox.Show(result.Msg); break; case ExeResult.Success: RefreshPage(); ShowMessage("导入成功!"); break; default: break; } } catch (Exception ex) { ShowError(ex); } finally { UnLockPage(); } }