public bool GoodsParseLine(string strValue, string strSplit, out CMSMStruct.GoodsStruct asstmp, out Exception err) { int i = 0; asstmp = new CMSMData.CMSMStruct.GoodsStruct(); err = null; try { string[] strFields = strValue.Split(strSplit.ToCharArray()); asstmp.strGoodsID = strFields[i++]; asstmp.strGoodsName = strFields[i++]; asstmp.strSpell = strFields[i++]; asstmp.dPrice = double.Parse(strFields[i++]); asstmp.dRate = double.Parse(strFields[i++]); asstmp.iIgValue = int.Parse(strFields[i++]); asstmp.strNewFlag = strFields[i++]; asstmp.strComments = strFields[i++]; } catch (Exception e) { err = e; return(false); } return(true); }
private void txtGoodsID_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if (e.KeyChar == 13 && txtGoodsID.Text.Trim() != "") { CMSMData.CMSMStruct.GoodsStruct gs = new CMSMData.CMSMStruct.GoodsStruct(); err = null; gs = cs.GetGoodsByID(txtGoodsID.Text.Trim(), out err); if (gs != null) { txtGoodsID.Text = gs.strGoodsID; cmbGoodsName.Text = gs.strGoodsName; txtPrice.Text = gs.dPrice.ToString(); txtCount.Text = "1"; txtCount.Focus(); } else { if (err != null) { clog.WriteLine(err); } MessageBox.Show("无此商品信息!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); cmbGoodsName.Text = "请输入..."; txtGoodsID.Focus(); return; } } }
private void cmbGoodsName_SelectedIndexChanged(object sender, System.EventArgs e) { if (cmbGoodsName.Text.Trim() != "") { string strSpell = cmbGoodsName.Text.Trim(); CMSMData.CMSMStruct.GoodsStruct gs = new CMSMData.CMSMStruct.GoodsStruct(); err = null; gs = cs.GetGoodsByName(cmbGoodsName.Text.Trim(), out err); if (gs != null) { txtGoodsID.Text = gs.strGoodsID; cmbGoodsName.Text = gs.strGoodsName; txtPrice.Text = gs.dPrice.ToString(); txtCount.Text = "1"; cmbGoodsName.Focus(); } else { if (err != null) { clog.WriteLine(err); } MessageBox.Show("无此商品信息!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); cmbGoodsName.Text = "请输入..."; cmbGoodsName.Focus(); return; } } }
private void cmbGoodsName_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if (e.KeyChar == 13 && cmbGoodsName.Text.Trim() != "") { string strSpell = cmbGoodsName.Text.Trim(); this.FillComboBoxBySpell(cmbGoodsName, "GoodsSpell", "vcGoodsName", "vcSpell", strSpell); CMSMData.CMSMStruct.GoodsStruct gs = new CMSMData.CMSMStruct.GoodsStruct(); err = null; gs = cs.GetGoodsByName(cmbGoodsName.Text.Trim(), out err); if (gs != null) { if (gs.iIgValue.ToString() == "-1") { MessageBox.Show("该商品无兑换积分值,不能兑换!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); txtGoodsID.Text = ""; txtIgPay.Text = ""; cmbGoodsName.Text = "请输入..."; cmbGoodsName.Focus(); return; } txtGoodsID.Text = gs.strGoodsID; cmbGoodsName.Text = gs.strGoodsName; txtIgPay.Text = gs.iIgValue.ToString(); txtIgPay.ReadOnly = true; txtCount.Text = "1"; txtCount.Focus(); } else { if (err != null) { clog.WriteLine(err); } MessageBox.Show("无此商品信息!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); cmbGoodsName.Text = "请输入..."; cmbGoodsName.Focus(); return; } } }
private void sbtnAdd_Click(object sender, System.EventArgs e) { if (SpecTypeIndex > -10 && SpecTypeIndex != this.cmbSepcialType.SelectedIndex) { MessageBox.Show("你所选择的特殊处理类型以之前录入商品的处理类型不一致!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } double dCount = 0; if (txtCount.Text.Trim() == "") { MessageBox.Show("数量不能为空!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } else { dCount = int.Parse(txtCount.Text.Trim()); } double dPrice = 0; if (SysInitial.TP == "1") { if (txtPrice.Text.Trim() == "") { MessageBox.Show("单价不能为空!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } else { dPrice = Double.Parse(txtPrice.Text.Trim()); } } if (txtGoodsID.Text.Trim() == "") { MessageBox.Show("商品信息有误,请重新选择商品!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); txtGoodsID.Text = ""; cmbGoodsName.Items.Clear(); cmbGoodsName.Refresh(); txtPrice.Text = "0"; txtCount.Text = ""; } CMSMData.CMSMStruct.GoodsStruct gs = new CMSMData.CMSMStruct.GoodsStruct(); err = null; gs = cs.GetGoodsByID(txtGoodsID.Text.Trim(), out err); if (gs != null) { txtGoodsID.Text = gs.strGoodsID; cmbGoodsName.Text = gs.strGoodsName; bool sumflag = false; for (int i = 0; i < dtConsItem.Rows.Count; i++) { if (gs.strGoodsID == dtConsItem.Rows[i]["GoodsID"].ToString()) { dtConsItem.Rows[i]["Count"] = (double.Parse(dtConsItem.Rows[i]["Count"].ToString()) + dCount).ToString(); dtConsItem.Rows[i]["Fee"] = (double.Parse(dtConsItem.Rows[i]["Fee"].ToString()) + (dPrice * dCount)).ToString(); sumflag = true; break; } } if (!sumflag) { DataRow dr = dtConsItem.NewRow(); dr[0] = gs.strGoodsID; dr[1] = gs.strGoodsName; dr[2] = dPrice.ToString(); dr[3] = dCount.ToString(); dr[4] = "0"; dr[5] = (dPrice * dCount).ToString(); dtConsItem.Rows.Add(dr); } if (SpecTypeIndex == -10) { SpecTypeIndex = this.cmbSepcialType.SelectedIndex; } if (this.cmbSepcialType.Enabled == true) { this.cmbSepcialType.Enabled = false; } this.DgBind(); cmbGoodsName.Focus(); } else { if (err != null) { clog.WriteLine(err); } MessageBox.Show("无此商品信息!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } }
private void txtCount_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if (e.KeyChar != 13) { if (e.KeyChar == 8) { return; } if (e.KeyChar < 48 || e.KeyChar > 57) { e.Handled = true; return; } } else { int dCount = 0; int LastIg = int.Parse(this.txtIgCur.Text.Trim()); if (txtCount.Text.Trim() == "") { MessageBox.Show("数量不能为空!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } else { dCount = int.Parse(txtCount.Text.Trim()); } int dIgPay = 0; if (txtIgPay.Text.Trim() == "") { MessageBox.Show("需要的积分不能为空!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } else { dIgPay = int.Parse(txtIgPay.Text.Trim()); } if (txtGoodsID.Text.Trim() == "") { MessageBox.Show("商品信息有误,请重新选择商品!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); txtGoodsID.Text = ""; cmbGoodsName.Items.Clear(); cmbGoodsName.Refresh(); txtIgPay.Text = ""; txtCount.Text = ""; } if ((int.Parse(txtTolCharge.Text.Trim()) + dIgPay) > LastIg) { MessageBox.Show("所剩积分不能再兑换此商品!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } CMSMData.CMSMStruct.GoodsStruct gs = new CMSMData.CMSMStruct.GoodsStruct(); err = null; gs = cs.GetGoodsByID(txtGoodsID.Text.Trim(), out err); if (gs != null) { txtGoodsID.Text = gs.strGoodsID; cmbGoodsName.Text = gs.strGoodsName; bool sumflag = false; for (int i = 0; i < dtIgItem.Rows.Count; i++) { if (gs.strGoodsID == dtIgItem.Rows[i]["GoodsID"].ToString()) { dtIgItem.Rows[i]["Count"] = (int.Parse(dtIgItem.Rows[i]["Count"].ToString()) + dCount).ToString(); dtIgItem.Rows[i]["IgPay"] = (int.Parse(dtIgItem.Rows[i]["IgPay"].ToString()) + (dIgPay * dCount)).ToString(); sumflag = true; break; } } if (!sumflag) { DataRow dr = dtIgItem.NewRow(); dr[0] = gs.strGoodsID; dr[1] = gs.strGoodsName; dr[2] = dIgPay.ToString(); dr[3] = dCount.ToString(); dr[4] = (dIgPay * dCount).ToString(); dtIgItem.Rows.Add(dr); } this.DgBind(); txtCount.Focus(); } else { if (err != null) { clog.WriteLine(err); } MessageBox.Show("无此商品信息!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } } }
private void sbtnMod_Click(object sender, System.EventArgs e) { if (sbtnMod.Text == "修改") { if (this.dataGrid1.CurrentRowIndex >= 0) { this.ClearText(); txtGoodsID.Text = dataGrid1[dataGrid1.CurrentRowIndex, 0].ToString(); txtGoodsName.Text = dataGrid1[dataGrid1.CurrentRowIndex, 1].ToString(); txtSpell.Text = dataGrid1[dataGrid1.CurrentRowIndex, 2].ToString(); txtPrice.Text = dataGrid1[dataGrid1.CurrentRowIndex, 3].ToString(); txtIgValue.Text = dataGrid1[dataGrid1.CurrentRowIndex, 4].ToString(); txtComments.Text = dataGrid1[dataGrid1.CurrentRowIndex, 5].ToString(); gsold = new CMSMData.CMSMStruct.GoodsStruct(); gsold.strGoodsID = dataGrid1[dataGrid1.CurrentRowIndex, 0].ToString(); gsold.strGoodsName = dataGrid1[dataGrid1.CurrentRowIndex, 1].ToString(); gsold.strSpell = dataGrid1[dataGrid1.CurrentRowIndex, 2].ToString(); gsold.dPrice = Double.Parse(dataGrid1[dataGrid1.CurrentRowIndex, 3].ToString()); gsold.iIgValue = int.Parse(dataGrid1[dataGrid1.CurrentRowIndex, 4].ToString()); gsold.strComments = dataGrid1[dataGrid1.CurrentRowIndex, 5].ToString(); sbtnMod.Text = "保存"; this.cmbGoodsType.Enabled = false; txtGoodsID.ReadOnly = true; sbtnDel.Enabled = false; txtGoodsName.ReadOnly = true; sbtnAdd.Enabled = false; } else { MessageBox.Show("没有选中要修改的商品信息!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } } else { CMSMData.CMSMStruct.GoodsStruct gs = new CMSMData.CMSMStruct.GoodsStruct(); if (txtGoodsName.Text.Trim() == "") { MessageBox.Show("商品名称不能为空!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } else { gs.strGoodsName = txtGoodsName.Text.Trim(); } if (txtPrice.Text.Trim() == "") { MessageBox.Show("商品单价不能为空!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } else { gs.dPrice = Double.Parse(txtPrice.Text.Trim()); } if (txtIgValue.Text.Trim() == "" || txtIgValue.Text.Trim() == "0" || int.Parse(txtIgValue.Text.Trim()) < -1) { MessageBox.Show("兑换分值不正确!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } else { gs.iIgValue = int.Parse(txtIgValue.Text.Trim()); } gs.strSpell = txtSpell.Text.Trim(); gs.strComments = txtComments.Text.Trim(); err = null; cs.UpdateGoods(gs, gsold, out err); if (err != null) { MessageBox.Show("修改商品信息失败,请重试!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); sbtnMod.Text = "修改"; txtGoodsID.ReadOnly = false; sbtnDel.Enabled = true; sbtnAdd.Enabled = true; this.ClearText(); this.DgBind(); clog.WriteLine(err); } else { MessageBox.Show("修改商品信息成功!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); err = null; SysInitial.CreatDS(out err); if (err != null) { MessageBox.Show("系统出错,将自动关闭,稍后请重新登录系统!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); clog.WriteLine(err); Application.Exit(); } sbtnMod.Text = "修改"; txtGoodsID.ReadOnly = false; sbtnDel.Enabled = true; sbtnAdd.Enabled = true; this.ClearText(); txtIgValue.Text = "-1"; this.DgBind(); } } }
private void sbtnAdd_Click(object sender, System.EventArgs e) { CMSMData.CMSMStruct.GoodsStruct gs = new CMSMData.CMSMStruct.GoodsStruct(); err = null; gs.strGoodsType = this.cmbGoodsType.Text.Trim(); if (!cs.ChkGoodsIDDup(txtGoodsID.Text.Trim(), out err)) { gs.strGoodsID = txtGoodsID.Text.Trim(); } else { MessageBox.Show("该编号已经存在,请重新输入!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); if (err != null) { clog.WriteLine(err); } txtGoodsID.Focus(); return; } if (txtGoodsName.Text.Trim() == "") { MessageBox.Show("商品名称不能为空!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } else if (!cs.ChkGoodsNameDup(txtGoodsName.Text.Trim(), out err)) { gs.strGoodsName = txtGoodsName.Text.Trim(); } else { MessageBox.Show("该商品名称已经存在,请重新输入!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); if (err != null) { clog.WriteLine(err); } txtGoodsName.Focus(); return; } if (txtPrice.Text.Trim() == "") { MessageBox.Show("商品单价不能为空!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } else { gs.dPrice = Double.Parse(txtPrice.Text.Trim()); } if (txtIgValue.Text.Trim() == "" || txtIgValue.Text.Trim() == "0" || int.Parse(txtIgValue.Text.Trim()) < -1) { MessageBox.Show("兑换分值不正确!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } else { gs.iIgValue = int.Parse(txtIgValue.Text.Trim()); } gs.strSpell = txtSpell.Text.Trim().ToLower(); gs.strComments = txtComments.Text.Trim(); err = null; cs.InsertGoods(gs, out err); if (err != null) { MessageBox.Show("添加商品信息失败,请重试!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); clog.WriteLine(err); } else { MessageBox.Show("添加商品信息成功!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); err = null; SysInitial.CreatDS(out err); if (err != null) { MessageBox.Show("系统出错,将自动关闭,稍后请重新登录系统!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); Application.Exit(); } this.ClearText(); txtIgValue.Text = "-1"; this.DgBind(); } }
private void AddGoodsToDataGrid() { double dCount = 0; if (txtCount.Text.Trim() == "") { MessageBox.Show("数量不能为空!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } else { dCount = int.Parse(txtCount.Text.Trim()); } double dPrice = 0; if (txtPrice.Text.Trim() == "") { MessageBox.Show("单价不能为空!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } else { dPrice = Double.Parse(txtPrice.Text.Trim()); } if (txtGoodsID.Text.Trim() == "") { MessageBox.Show("商品信息有误,请重新选择商品!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); txtGoodsID.Text = ""; cmbGoodsName.Items.Clear(); cmbGoodsName.Refresh(); txtPrice.Text = ""; txtCount.Text = ""; } CMSMData.CMSMStruct.GoodsStruct gs = new CMSMData.CMSMStruct.GoodsStruct(); err = null; gs = cs.GetGoodsByID(txtGoodsID.Text.Trim(), out err); if (gs != null) { txtGoodsID.Text = gs.strGoodsID; cmbGoodsName.Text = gs.strGoodsName; bool sumflag = false; foreach (DataRow dr in dtConsItem.Rows) { if (gs.strGoodsID == dr["GoodsID"].ToString()) { dr["Count"] = (double.Parse(dr["Count"].ToString()) + dCount).ToString(); sumflag = true; break; } } if (!sumflag) { switch (this.formType) { case FormType.ProductionInStorage: if (cs.ProductionInStorageExist(SysInitial.CurOps.strDeptID, dtpInDate.Text, txtGoodsID.Text)) { MessageBox.Show("此商品已入库", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning); return; } break; case FormType.SaleCheck: if (cs.SaleCheckExist(SysInitial.CurOps.strDeptID, dtpInDate.Text, txtGoodsID.Text)) { MessageBox.Show("此商品已盘点", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning); return; } break; } DataRow dr = dtConsItem.NewRow(); dr[0] = "0"; dr[1] = gs.strGoodsID; dr[2] = gs.strGoodsName; dr[3] = dPrice.ToString(); dr[4] = dCount.ToString(); dtConsItem.Rows.Add(dr); } this.DgBind(); cmbGoodsName.Focus(); } else { if (err != null) { clog.WriteLine(err); } MessageBox.Show("无此商品信息!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } }
private void AddGoodsToDataGrid() { double dCount = 0; if (txtCount.Text.Trim() == "") { MessageBox.Show("数量不能为空!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } else { dCount = int.Parse(txtCount.Text.Trim()); } double dPrice = 0; if (txtPrice.Text.Trim() == "") { MessageBox.Show("单价不能为空!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } else { dPrice = Double.Parse(txtPrice.Text.Trim()); } if (txtGoodsID.Text.Trim() == "") { MessageBox.Show("商品信息有误,请重新选择商品!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); txtGoodsID.Text = ""; cmbGoodsName.Items.Clear(); cmbGoodsName.Refresh(); txtPrice.Text = ""; txtCount.Text = ""; } CMSMData.CMSMStruct.GoodsStruct gs = new CMSMData.CMSMStruct.GoodsStruct(); err = null; gs = cs.GetGoodsByID(txtGoodsID.Text.Trim(), out err); if (gs != null) { txtGoodsID.Text = gs.strGoodsID; cmbGoodsName.Text = gs.strGoodsName; bool sumflag = false; for (int i = 0; i < dtConsItem.Rows.Count; i++) { if (gs.strGoodsID == dtConsItem.Rows[i]["GoodsID"].ToString()) { dtConsItem.Rows[i]["Count"] = (double.Parse(dtConsItem.Rows[i]["Count"].ToString()) + dCount).ToString(); sumflag = true; break; } } if (!sumflag) { DataRow dr = dtConsItem.NewRow(); dr[0] = gs.strGoodsID; dr[1] = gs.strGoodsName; dr[2] = dPrice.ToString(); dr[3] = dCount.ToString(); dtConsItem.Rows.Add(dr); } this.DgBind(); cmbGoodsName.Focus(); } else { if (err != null) { clog.WriteLine(err); } MessageBox.Show("无此商品信息!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } }