/// <summary> /// 确定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void simpleButtonConfirm_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textEditUnitName.Text)) { XtraMessageBox.Show("请输入计量单位名称!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error); textEditUnitName.Focus(); return; } //验证比例为1-5位小数的正实数 if (string.IsNullOrEmpty(textEditNum.Text) || textEditNum.Text == "0") { XtraMessageBox.Show("请输入正确的比例关系!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error); textEditNum.Focus(); return; } WaitDialogForm waitForm = new WaitDialogForm(Constants.OPERATE_DB_DATA); waitForm.Show(); Alading.Entity.StockUnit stockUnit = new Alading.Entity.StockUnit(); stockUnit.StockUnitName = textEditUnitName.Text; stockUnit.Conversion = double.Parse(textEditNum.Text); stockUnit.Remark = memoExEditRemark.Text; if (StockUnitService.UpdateStockUnit(stockunitCode, stockUnit) == ReturnType.Success) { waitForm.Close(); XtraMessageBox.Show("计量单位修改成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { waitForm.Close(); XtraMessageBox.Show("计量单位修改失败!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// 确定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void simpleButtonConfirm_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(comboBoxGroup.Text)) { XtraMessageBox.Show("请选择计量单位组!", Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (string.IsNullOrEmpty(textEditUnitName.Text)) { XtraMessageBox.Show("请输入计量单位名称!", Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Error); textEditUnitName.Focus(); return; } //验证比例为1-5位小数的正实数 if (string.IsNullOrEmpty(textEditNum.Text) || textEditNum.Text == "0") { XtraMessageBox.Show("请输入正确的比例关系!", Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Error); textEditNum.Focus(); return; } WaitDialogForm waitForm = new WaitDialogForm(Constants.OPERATE_DB_DATA); waitForm.Show(); try { Alading.Entity.StockUnit stockUnit = new Alading.Entity.StockUnit(); if (string.IsNullOrEmpty(textEditCode.Text) || string.IsNullOrEmpty(textEditCode.Text.Trim())) { stockUnit.StockUnitCode = System.Guid.NewGuid().ToString(); } else { stockUnit.StockUnitCode = textEditCode.Text; } stockUnit.StockUnitName = textEditUnitName.Text; stockUnit.StockUnitSource = "手动新增"; stockUnit.Conversion = float.Parse(textEditNum.Text); stockUnit.IsBaseUnit = false; stockUnit.StockUnitGroupCode = stockgroupUnitCode; stockUnit.Remark = memoExEditRemark.Text; if (StockUnitService.AddStockUnit(stockUnit) == ReturnType.Success) { waitForm.Close(); XtraMessageBox.Show("计量单位添加成功!", Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; this.Close(); } else { waitForm.Close(); XtraMessageBox.Show("计量单位添加失败!", Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { waitForm.Close(); XtraMessageBox.Show(ex.Message, Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public ModifyUnitForm(string stockUnitCode, string unitGroupName, string baseUnitName) { InitializeComponent(); textUnitGroup.Text = unitGroupName; labelBaseUnit.Text = baseUnitName; this.stockunitCode = stockUnitCode; List <string> listStockUnitCode = new List <string>(); List <Alading.Entity.StockUnit> stockUnitlist = StockUnitService.GetStockUnit(c => c.StockUnitCode == stockUnitCode); if (stockUnitlist != null && stockUnitlist.Count > 0) { Alading.Entity.StockUnit stockunit = stockUnitlist.First(); textEditUnitName.Text = stockunit.StockUnitName; textEditNum.Text = stockunit.Conversion.ToString(); memoExEditRemark.Text = stockunit.Remark; textEditCode.Text = stockunit.StockUnitCode; } else { this.Close(); } }
private void btnAdd_Click(object sender, EventArgs e) { WaitDialogForm waitForm = new WaitDialogForm(Constants.OPERATE_DB_DATA); waitForm.Show(); try { #region 验证 if (string.IsNullOrEmpty(textEditGroupName.Text) || string.IsNullOrEmpty(textEditGroupName.Text.Trim())) { waitForm.Close(); XtraMessageBox.Show("请输入单位组名称!", Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information); textEditGroupName.Focus(); return; } if (string.IsNullOrEmpty(textEditBaseUnitName.Text) || string.IsNullOrEmpty(textEditBaseUnitName.Text.Trim())) { waitForm.Close(); XtraMessageBox.Show("请输入基本单位名称!", Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information); textEditBaseUnitName.Focus(); return; } #endregion StockUnitGroup sug = new StockUnitGroup(); Alading.Entity.StockUnit unit = new Alading.Entity.StockUnit(); /*基本单位编码*/ if (string.IsNullOrEmpty(textEditBaseUnitCode.Text) || string.IsNullOrEmpty(textEditBaseUnitCode.Text.Trim())) { unit.StockUnitCode = System.Guid.NewGuid().ToString(); } else { unit.StockUnitCode = textEditBaseUnitCode.Text; } /*单位组编码*/ if (string.IsNullOrEmpty(textEditGroupCode.Text) || string.IsNullOrEmpty(textEditGroupCode.Text.Trim())) { sug.StockUnitGroupCode = System.Guid.NewGuid().ToString(); } else { sug.StockUnitGroupCode = textEditGroupCode.Text; } if (!StockUnitGroupService.IsCodeOnly(unit.StockUnitCode, sug.StockUnitGroupCode)) { XtraMessageBox.Show("单位或单位组编码输入与数据库中重复,请重输!", Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information); waitForm.Close(); return; } unit.Conversion = 1; unit.IsBaseUnit = true; unit.Remark = memoExEdit1.Text; unit.StockUnitGroupCode = sug.StockUnitGroupCode; unit.StockUnitName = textEditBaseUnitName.Text; unit.StockUnitSource = "手动添加"; sug.StockUnitGroupName = textEditGroupName.Text; sug.BaseUnit = unit.StockUnitName;// sug.Remark = memoRemark.Text; waitForm.Close(); if (StockUnitGroupService.AddStockUnitGroup(sug, unit) == ReturnType.Success) { XtraMessageBox.Show("添加单位组成功!", Constants.SYSTEM_PROMPT); } else { XtraMessageBox.Show("添加单位组失败!", Constants.SYSTEM_PROMPT); } this.DialogResult = DialogResult.OK; } catch (Exception ex) { waitForm.Close(); XtraMessageBox.Show(ex.ToString(), Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information); } }