/* * 方法名称:DataGrilViedAddRow() * 方法功能描述:向table中增加一行; * * 创建人:冯雪 * 创建时间:2009-03-07 * * 修改人: * 修改时间: * 修改内容: * */ public void DataGrilViedAddRow(InvoiceClass invoiceClass, DataTable dt, string pKind, string pName, string pModel) { DataRow dr = dt.NewRow(); dr["id"] = invoiceClass.Id; dr["pid"] = invoiceClass.PId; dr["sort"] = pKind; dr["name"] = pName; dr["model"] = pModel; dr["quantity"] = invoiceClass.Quantity; dr["unitPrice"] = invoiceClass.UnitPrice; dr["inputMan"] = invoiceClass.InputMan; dr["inputDate"] = invoiceClass.InputDate; dr["finishMark"] = invoiceClass.FinishMark ? "执行" : "可编辑"; dt.Rows.Add(dr); }
/* * 方法名称: GetIndent() * 方法功能描述:销售合同明细信息; * * 创建人:冯雪 * 创建时间:2009-03-10 * * 修改人: * 修改时间: * 修改内容: * */ private List <InvoiceClass> GetIndent() { InvoiceClass invoiceClass = null; List <InvoiceClass> list = new List <InvoiceClass>(); foreach (DataGridViewRow dgvr in dgvdetail.Rows) { invoiceClass = new InvoiceClass(); invoiceClass.PId = int.Parse(dgvr.Cells["pid"].Value.ToString()); invoiceClass.Quantity = Convert.ToInt32(dgvr.Cells["quantity"].Value.ToString()); invoiceClass.UnitPrice = decimal.Parse(dgvr.Cells["unitPrice"].Value.ToString()); invoiceClass.InputMan = dgvr.Cells["inputMan"].Value.ToString(); invoiceClass.InputDate = DateTime.Parse(dgvr.Cells["inputDate"].Value.ToString()); list.Add(invoiceClass); } return(list); }
private void btnAdd_Click(object sender, EventArgs e) { // 2009-4-17 修改人:付中华 //对所有明细信息进行校验 #region if (!Check.CheckEmpty(cbxPKind.Text.ToString())) { MessageBox.Show("产品种类不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); cbxPKind.Focus(); return; } if (!Check.CheckEmpty(cbxPName.Text.ToString())) { MessageBox.Show("产品名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); cbxPName.Focus(); return; } if (!Check.CheckEmpty(cbxPModel.Text.ToString())) { MessageBox.Show("产品规格不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); cbxPModel.Focus(); return; } if (!Check.CheckEmpty(txtQuantity.Text.ToString())) { MessageBox.Show("销售数量不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); txtQuantity.Focus(); return; } else { if (!Check.CheckFloat(txtQuantity.Text.ToString())) { MessageBox.Show("销售总数量含非法字符!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); txtQuantity.Clear(); txtQuantity.Focus(); return; } } if (!Check.CheckEmpty(txtUnitPrice.Text.ToString())) { MessageBox.Show("销售单价不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); txtUnitPrice.Focus(); return; } else { if (!Check.CheckFloat(txtUnitPrice.Text.ToString())) { MessageBox.Show("销售单价含有非法字符!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); txtUnitPrice.Clear(); txtUnitPrice.Focus(); return; } } #endregion // 处理两条明细相同时给予提示信息 if (dgvdetail.Rows.Count != 0) { foreach (DataGridViewRow dgvr in dgvdetail.Rows) { if (dgvr.Cells["pkind"].Value.ToString() == cbxPKind.Text.ToString() && dgvr.Cells["pname"].Value.ToString() == cbxPName.Text.ToString() && dgvr.Cells["pmodle"].Value.ToString() == cbxPModel.Text.ToString()) { if (MessageBox.Show("确定添加相同种类名称规格的产品合同明细吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK) { } else { return; } } } } //if (formHelper.inputCheck(groupBox2)) //{ InvoiceClass invoiceClass = new InvoiceClass(); int pnid = Convert.ToInt32(this.cbxPName.SelectedValue.ToString()); int pmid = Convert.ToInt32(this.cbxPModel.SelectedValue.ToString()); // 提取销售合同明细内容; invoiceClass.PId = pLogic.PSearchID(pnid, pmid); invoiceClass.InputMan = this.userName; invoiceClass.InputDate = DateTime.Now; invoiceClass.UnitPrice = decimal.Parse(this.txtUnitPrice.Text.Trim()); invoiceClass.Quantity = Convert.ToInt32(this.txtQuantity.Text.Trim()); aSCLogic.DataGrilViedAddRow(invoiceClass, ds.Tables[0], cbxPKind.Text, cbxPName.Text, cbxPModel.Text); // 2009-4-17 添加调用方法 caleTotalMoneyAndTotalWeight(); ClearAction(); //} }