public static int GetProductSizeFlag(string productid) { dalProductList dal = new dalProductList(); modProductList mod = dal.GetItem(productid, out Util.emsg); if (mod != null) { return(mod.SizeFlag); } else { return(0); } }
/// <summary> /// get productlist by page /// <summary> /// <param name=currentPage>currentPage</param> /// <param name=pagesize>pagesize</param> /// <param name=productname>productname</param> /// <param name=out emsg>return error message</param> ///<returns>details of all productlist</returns> public BindingCollection <modProductList> GetIList(int currentPage, int pagesize, string productname, out string emsg) { try { string productnamewhere = string.Empty; if (!string.IsNullOrEmpty(productname)) { productnamewhere = "and product_name like '" + productname + "%' "; } BindingCollection <modProductList> modellist = new BindingCollection <modProductList>(); //Execute a query to read the categories int startindex = (currentPage - 1) * pagesize + 1; int endindex = currentPage * pagesize; string sql = "select row_number() over(order by product_id) as rn,product_id,product_name,product_type,barcode,size_flag,specify,brand,unit_no,remark,min_qty,max_qty,update_user,update_time from product_list where status<>7 " + productnamewhere; string sql2 = "select count(1) from (" + sql + ") t"; sql = string.Format("select * from (" + sql + ") t where rn>='{0}' and rn<='{1}'", startindex, endindex); using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql)) { while (rdr.Read()) { modProductList model = new modProductList(); model.ProductId = dalUtility.ConvertToString(rdr["product_id"]); model.ProductName = dalUtility.ConvertToString(rdr["product_name"]); model.ProductType = dalUtility.ConvertToString(rdr["product_type"]); model.Barcode = dalUtility.ConvertToString(rdr["barcode"]); model.SizeFlag = dalUtility.ConvertToInt(rdr["size_flag"]); model.Specify = dalUtility.ConvertToString(rdr["specify"]); model.Brand = dalUtility.ConvertToString(rdr["brand"]); model.UnitNo = dalUtility.ConvertToString(rdr["unit_no"]); model.Remark = dalUtility.ConvertToString(rdr["remark"]); model.MinQty = dalUtility.ConvertToDecimal(rdr["min_qty"]); model.MaxQty = dalUtility.ConvertToDecimal(rdr["max_qty"]); model.UpdateUser = dalUtility.ConvertToString(rdr["update_user"]); model.UpdateTime = dalUtility.ConvertToDateTime(rdr["update_time"]); modellist.Add(model); } } emsg = SqlHelper.ExecuteScalar(sql2).ToString(); return(modellist); } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(null); } }
private void DBGrid_SelectionChanged(object sender, EventArgs e) { if (DBGrid.CurrentRow != null) { modProductList mod = (modProductList)DBGrid.CurrentRow.DataBoundItem; txtProductId.Text = mod.ProductId; txtProductName.Text = mod.ProductName; txtBarcode.Text = mod.Barcode; txtSpecify.Text = mod.Specify; txtBrand.Text = mod.Brand; cboUnitNo.SelectedValue = mod.UnitNo; txtRemark.Text = mod.Remark; txtMinQty.Text = mod.MinQty.ToString(); txtMaxQty.Text = mod.MaxQty.ToString(); cboSizeFlag.SelectedIndex = mod.SizeFlag == 0 ? 1 : 0; //FindText = mod.ProductName; LoadPriceData(mod.ProductId); } }
/// <summary> /// get table record /// <summary> /// <param name=productname>productname</param> /// <param name=out emsg>return error message</param> ///<returns>get a record detail of productlist</returns> public modProductList GetItembyName(string productname, out string emsg) { try { //Execute a query to read the categories string sql = string.Format("select product_id,product_name,product_type,barcode,size_flag,specify,brand,unit_no,remark,min_qty,max_qty,update_user,update_time from product_list where product_name='{0}' order by product_type,product_id", productname); using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql)) { if (rdr.Read()) { modProductList model = new modProductList(); model.ProductId = dalUtility.ConvertToString(rdr["product_id"]); model.ProductName = dalUtility.ConvertToString(rdr["product_name"]); model.ProductType = dalUtility.ConvertToString(rdr["product_type"]); model.Barcode = dalUtility.ConvertToString(rdr["barcode"]); model.SizeFlag = dalUtility.ConvertToInt(rdr["size_flag"]); model.Specify = dalUtility.ConvertToString(rdr["specify"]); model.Brand = dalUtility.ConvertToString(rdr["brand"]); model.UnitNo = dalUtility.ConvertToString(rdr["unit_no"]); model.Remark = dalUtility.ConvertToString(rdr["remark"]); model.MinQty = dalUtility.ConvertToDecimal(rdr["min_qty"]); model.MaxQty = dalUtility.ConvertToDecimal(rdr["max_qty"]); model.UpdateUser = dalUtility.ConvertToString(rdr["update_user"]); model.UpdateTime = dalUtility.ConvertToDateTime(rdr["update_time"]); emsg = null; return(model); } else { emsg = "Error on read data"; return(null); } } } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(null); } }
private void mnuAdd_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; MTN_PRODUCT_LIST frm = new MTN_PRODUCT_LIST(); frm.SelectVisible = true; if (frm.ShowDialog() == DialogResult.OK) { dalProductList dal = new dalProductList(); modProductList mod = dal.GetItem(Util.retValue1, out Util.emsg); if (mod != null) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(DBGrid); row.Cells[0].Value = mod.ProductId; row.Cells[1].Value = mod.ProductName; row.Cells[2].Value = mod.Specify; row.Cells[3].Value = mod.UnitNo; row.Cells[4].Value = mod.Brand; row.Cells[5].Value = 1; row.Cells[6].Value = 0; row.Cells[7].Value = ""; row.Height = 40; DBGrid.Rows.Add(row); row.Dispose(); } } } catch (Exception ex) { MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } finally { this.Cursor = Cursors.Default; } }
/// <summary> /// get all productlist /// <summary> /// <param name=producttypelist>producttypelist</param> /// <param name=out emsg>return error message</param> ///<returns>details of all productlist</returns> public BindingCollection <modProductList> GetIListByBarcode(string barcode, out string emsg) { try { BindingCollection <modProductList> modellist = new BindingCollection <modProductList>(); //Execute a query to read the categories string sql = string.Format("select product_id,product_name,product_type,barcode,size_flag,specify,brand,unit_no,remark,min_qty,max_qty,update_user,update_time " + "from product_list where status<>7 and barcode = '{0}' order by product_type,product_id", barcode); using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql)) { while (rdr.Read()) { modProductList model = new modProductList(); model.ProductId = dalUtility.ConvertToString(rdr["product_id"]); model.ProductName = dalUtility.ConvertToString(rdr["product_name"]); model.ProductType = dalUtility.ConvertToString(rdr["product_type"]); model.Barcode = dalUtility.ConvertToString(rdr["barcode"]); model.SizeFlag = dalUtility.ConvertToInt(rdr["size_flag"]); model.Specify = dalUtility.ConvertToString(rdr["specify"]); model.Brand = dalUtility.ConvertToString(rdr["brand"]); model.UnitNo = dalUtility.ConvertToString(rdr["unit_no"]); model.Remark = dalUtility.ConvertToString(rdr["remark"]); model.MinQty = dalUtility.ConvertToDecimal(rdr["min_qty"]); model.MaxQty = dalUtility.ConvertToDecimal(rdr["max_qty"]); model.UpdateUser = dalUtility.ConvertToString(rdr["update_user"]); model.UpdateTime = dalUtility.ConvertToDateTime(rdr["update_time"]); modellist.Add(model); } } emsg = null; return(modellist); } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(null); } }
/// <summary> /// update a productlist /// <summary> /// <param name=productid>productid</param> /// <param name=mod>model object of productlist</param> /// <param name=out emsg>return error message</param> /// <returns>true/false</returns> public bool Update(string productid, modProductList mod, out string emsg) { try { string sql = string.Format("update product_list set product_name='{0}',product_type='{1}',size_flag={2},specify='{3}',brand='{4}',unit_no='{5}',remark='{6}',min_qty={7},max_qty={8},update_user='******',update_time=getdate(), barcode='{10}', status=1 where product_id='{11}'", mod.ProductName, mod.ProductType, mod.SizeFlag, mod.Specify, mod.Brand, mod.UnitNo, mod.Remark, mod.MinQty, mod.MaxQty, mod.UpdateUser, mod.Barcode, productid); int i = SqlHelper.ExecuteNonQuery(sql); if (i > 0) { emsg = null; return(true); } else { emsg = "Unknown error when ExecuteNonQuery!"; return(false); } } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(false); } }
/// <summary> /// insert a productlist /// <summary> /// <param name=mod>model object of productlist</param> /// <param name=out emsg>return error message</param> /// <returns>true/false</returns> public bool Insert(modProductList mod, out string emsg) { try { string sql = string.Format("insert into product_list(product_id,product_name,product_type,status,size_flag,specify,brand,unit_no,remark,min_qty,max_qty,update_user,update_time,barcode)values('{0}','{1}','{2}',1,{3},'{4}','{5}','{6}','{7}',{8},{9},'{10}',getdate(),'{11}')", mod.ProductId, mod.ProductName, mod.ProductType, mod.SizeFlag, mod.Specify, mod.Brand, mod.UnitNo, mod.Remark, mod.MinQty, mod.MaxQty, mod.UpdateUser, mod.Barcode); int i = SqlHelper.ExecuteNonQuery(sql); if (i > 0) { emsg = null; return(true); } else { emsg = "Unknown error when ExecuteNonQuery!"; return(false); } } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(false); } }
private void toolExport_Click(object sender, EventArgs e) { if (DBGrid.CurrentRow == null) { return; } IList <modExcelRangeData> list = new List <modExcelRangeData>(); decimal summny = 0; string custid = string.Empty; string custorderno = string.Empty; dalProductList dalpdt = new dalProductList(); if (DBGrid.SelectedRows.Count == 0) { for (int i = 0; i < DBGrid.RowCount; i++) { if (DBGrid.Rows[i].Visible) { modCustomerOrderList modd = (modCustomerOrderList)DBGrid.Rows[i].DataBoundItem; if (string.IsNullOrEmpty(custid)) { dalCustomerList dalcust = new dalCustomerList(); modCustomerList modcust = dalcust.GetItem(modd.CustId, out Util.emsg); custid = modd.CustId; custorderno = modd.CustOrderNo; list.Add(new modExcelRangeData(modcust.FullName, "B6", "E6")); list.Add(new modExcelRangeData(modd.CustOrderNo, "I6", "I6")); list.Add(new modExcelRangeData(modd.FormDate.ToString("yyyy年MM月dd日"), "I7", "I7")); } else { if (custid != modd.CustId) { MessageBox.Show("您所选的订单必须属于同一个客户!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (custorderno != modd.CustOrderNo) { if (MessageBox.Show("您所选的订单不是同一个订单编号,是否要继续?", clsTranslate.TranslateString("Confirm"), MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == DialogResult.No) { return; } } } string col = (10 + i).ToString().Trim(); list.Add(new modExcelRangeData(modd.ProductName, "B" + col, "B" + col)); modProductList modpdt = dalpdt.GetItem(modd.ProductId, out Util.emsg); if (modpdt != null) { list.Add(new modExcelRangeData(modpdt.Brand, "C" + col, "C" + col)); } list.Add(new modExcelRangeData(modd.Qty.ToString(), "D" + col, "D" + col)); list.Add(new modExcelRangeData(modd.UnitNo, "E" + col, "E" + col)); list.Add(new modExcelRangeData(string.Format("{0:C2}", modd.Price), "G" + col, "G" + col)); list.Add(new modExcelRangeData(string.Format("{0:C2}", modd.Qty * modd.Price), "H" + col, "H" + col)); list.Add(new modExcelRangeData(modd.Remark, "I" + col, "I" + col)); summny = modd.Qty * modd.Price; } } list.Add(new modExcelRangeData("金额大写:" + clsMoney.ConvertToMoney(Convert.ToDouble(summny)), "A23", "I23")); list.Add(new modExcelRangeData(string.Format("{0:C2}", summny), "H22", "H22")); } else { for (int i = 0; i < DBGrid.SelectedRows.Count; i++) { if (DBGrid.SelectedRows[i].Visible) { modCustomerOrderList modd = (modCustomerOrderList)DBGrid.SelectedRows[i].DataBoundItem; if (string.IsNullOrEmpty(custid)) { dalCustomerList dalcust = new dalCustomerList(); modCustomerList modcust = dalcust.GetItem(modd.CustId, out Util.emsg); custid = modd.CustId; custorderno = modd.CustOrderNo; list.Add(new modExcelRangeData(modcust.FullName, "B6", "E6")); list.Add(new modExcelRangeData(modd.CustOrderNo, "I6", "I6")); list.Add(new modExcelRangeData(modd.FormDate.ToString("yyyy年MM月dd日"), "I7", "I7")); } else { if (custid != modd.CustId) { MessageBox.Show("您所选的订单必须属于同一个客户!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (custorderno != modd.CustOrderNo) { if (MessageBox.Show("您所选的订单不是同一个订单编号,是否要继续?", clsTranslate.TranslateString("Confirm"), MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == DialogResult.No) { return; } } } string col = (10 + i).ToString().Trim(); list.Add(new modExcelRangeData(modd.ProductName, "B" + col, "B" + col)); modProductList modpdt = dalpdt.GetItem(modd.ProductId, out Util.emsg); if (modpdt != null) { list.Add(new modExcelRangeData(modpdt.Brand, "C" + col, "C" + col)); } list.Add(new modExcelRangeData(modd.Qty.ToString(), "D" + col, "D" + col)); list.Add(new modExcelRangeData(modd.UnitNo, "E" + col, "E" + col)); list.Add(new modExcelRangeData(string.Format("{0:C2}", modd.Price), "G" + col, "G" + col)); list.Add(new modExcelRangeData(string.Format("{0:C2}", modd.Qty * modd.Price), "H" + col, "H" + col)); list.Add(new modExcelRangeData(modd.Remark, "I" + col, "I" + col)); summny = modd.Qty * modd.Price; } } list.Add(new modExcelRangeData("金额大写:" + clsMoney.ConvertToMoney(Convert.ToDouble(summny)), "A23", "I23")); list.Add(new modExcelRangeData(string.Format("{0:C2}", summny), "H22", "H22")); } clsExport.ExportByTemplate(list, "购销合同", 1, 38, 9, 1); }
protected override bool Save() { try { this.Cursor = Cursors.WaitCursor; if (string.IsNullOrEmpty(txtProductId.Text.Trim())) { MessageBox.Show(clsTranslate.TranslateString("Product Id") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtProductId.Focus(); return(false); } if (string.IsNullOrEmpty(txtProductName.Text.Trim())) { MessageBox.Show(clsTranslate.TranslateString("Product Name") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtProductName.Focus(); return(false); } if (cboUnitNo.SelectedIndex == -1) { MessageBox.Show(clsTranslate.TranslateString("Unit No") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboUnitNo.Focus(); return(false); } if (cboSizeFlag.Visible && cboSizeFlag.SelectedIndex == -1) { MessageBox.Show(clsTranslate.TranslateString("Size Flag") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboSizeFlag.Focus(); return(false); } if (string.IsNullOrEmpty(txtMinQty.Text.Trim())) { MessageBox.Show(clsTranslate.TranslateString("Min Qty") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtMinQty.Focus(); return(false); } else if (!Util.IsNumeric(txtMinQty.Text)) { MessageBox.Show(clsTranslate.TranslateString("Min Qty") + clsTranslate.TranslateString(" must be a numeric!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtMinQty.Focus(); return(false); } if (string.IsNullOrEmpty(txtMaxQty.Text.Trim())) { MessageBox.Show(clsTranslate.TranslateString("Max Qty") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtMaxQty.Focus(); return(false); } else if (!Util.IsNumeric(txtMaxQty.Text)) { MessageBox.Show(clsTranslate.TranslateString("Max Qty") + clsTranslate.TranslateString(" must be a numeric!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtMaxQty.Focus(); return(false); } modProductList mod = new modProductList(); mod.ProductId = txtProductId.Text.Trim(); mod.ProductName = txtProductName.Text.Trim(); mod.ProductType = _productType; mod.Barcode = txtBarcode.Text.Trim(); mod.Specify = txtSpecify.Text.Trim(); mod.Brand = txtBrand.Text.Trim(); mod.UnitNo = cboUnitNo.SelectedValue.ToString(); mod.Remark = txtRemark.Text.Trim(); mod.MinQty = Convert.ToDecimal(txtMinQty.Text); mod.MaxQty = Convert.ToDecimal(txtMaxQty.Text); if (cboSizeFlag.Visible) { mod.SizeFlag = cboSizeFlag.SelectedIndex == 0 ? 1 : 0; } else { mod.SizeFlag = 0; } mod.UpdateUser = Util.UserId; bool ret = false; if (_status == 1) { if (_dal.Exists(mod.ProductId, out Util.emsg)) { ret = _dal.Update(txtProductId.Text, mod, out Util.emsg); } else { ret = _dal.Insert(mod, out Util.emsg); } } else if (_status == 2) { ret = _dal.Update(txtProductId.Text, mod, out Util.emsg); } if (ret) { Util.ChangeStatus(this, true); DBGrid.Enabled = true; toolSavePrice.Enabled = true; LoadData(); FindText = mod.ProductName; Find(); } return(ret); } catch (Exception ex) { MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } finally { this.Cursor = Cursors.Default; } }
protected override void Find() { if (DBGrid.CurrentRow == null) { return; } for (int i = 0; i < DBGrid.Rows.Count; i++) { DBGrid.Rows[i].Visible = true; } int startindex = 0; if (DBGrid.CurrentRow.Index < DBGrid.RowCount - 1) { startindex = DBGrid.CurrentRow.Index + 1; } string[] finds = FindText.ToUpper().Split('*'); string flag = clsLxms.GetParameterValue("HIDE_NOT_MATCH_PRODUCT"); if (flag == "F") //不隐藏不匹配的 { bool find = false; for (int i = startindex; i < DBGrid.Rows.Count; i++) { bool found = true; modProductList mod = (modProductList)DBGrid.Rows[i].DataBoundItem; for (int j = 0; j < finds.Length; j++) { if (mod.ProductName.IndexOf(finds[j]) < 0 || (!string.IsNullOrEmpty(mod.Barcode) && mod.Barcode.IndexOf(finds[j]) < 0)) { found = false; } } if (found) { DBGrid.CurrentCell = DBGrid.Rows[i].Cells[0]; DBGrid_SelectionChanged(null, null); find = true; return; } } if (!find) { for (int i = 0; i < DBGrid.Rows.Count; i++) { bool found = true; modProductList mod = (modProductList)DBGrid.Rows[i].DataBoundItem; for (int j = 0; j < finds.Length; j++) { if (mod.ProductName.IndexOf(finds[j]) < 0 || (!string.IsNullOrEmpty(mod.Barcode) && mod.Barcode.IndexOf(finds[j]) < 0)) { found = false; } } if (found) { DBGrid.CurrentCell = DBGrid.Rows[i].Cells[0]; DBGrid_SelectionChanged(null, null); find = true; return; } } } } else //隐藏不匹配的 { DBGrid.CurrentCell = null; for (int i = 0; i < DBGrid.Rows.Count; i++) { bool found = true; modProductList mod = (modProductList)DBGrid.Rows[i].DataBoundItem; for (int j = 0; j < finds.Length; j++) { if (mod.ProductName.IndexOf(finds[j]) < 0 || (!string.IsNullOrEmpty(mod.Barcode) && mod.Barcode.IndexOf(finds[j]) < 0)) { found = false; break; } } if (found) { DBGrid.Rows[i].Visible = true; } else { DBGrid.Rows[i].Visible = false; } } } }
private void txtProduct_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == Convert.ToChar(Keys.Enter) || e.KeyChar == Convert.ToChar(Keys.Space)) { dalProductSalePrice dalprice = new dalProductSalePrice(); dalProductList dal = new dalProductList(); BindingCollection <modProductList> list = dal.GetIListByBarcode(txtProduct.Text.Trim(), out Util.emsg); if (list != null && list.Count > 0) { if (list.Count == 1) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(DBGrid); row.Height = 40; row.Cells[0].Value = list[0].ProductId; row.Cells[1].Value = list[0].ProductName; row.Cells[2].Value = list[0].Barcode; row.Cells[3].Value = list[0].UnitNo; row.Cells[4].Value = 1; row.Cells[5].Value = dalprice.GetDefaultPrice(list[0].ProductId, out Util.emsg); row.Cells[6].Value = decimal.Parse(row.Cells[5].Value.ToString()); row.Cells[8].Value = list[0].Specify; DBGrid.Rows.Add(row); row.Dispose(); } else { frmViewList frm = new frmViewList(); frm.InitViewList("请选择商品:", list); frm.Selection = true; if (frm.ShowDialog() == DialogResult.OK) { var modPdt = list.Where(c => c.ProductId == Util.retValue1).First(); DataGridViewRow row = new DataGridViewRow(); row.CreateCells(DBGrid); row.Height = 40; row.Cells[0].Value = modPdt.ProductId; row.Cells[1].Value = modPdt.ProductName; row.Cells[2].Value = modPdt.Barcode; row.Cells[3].Value = modPdt.UnitNo; row.Cells[4].Value = 1; row.Cells[5].Value = dalprice.GetDefaultPrice(modPdt.ProductId, out Util.emsg); row.Cells[6].Value = decimal.Parse(row.Cells[5].Value.ToString()); row.Cells[8].Value = modPdt.Specify; DBGrid.Rows.Add(row); row.Dispose(); } } SumData(); } else { modProductList mod = dal.GetItem(txtProduct.Text.Trim(), out Util.emsg); if (mod != null) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(DBGrid); row.Height = 40; row.Cells[0].Value = mod.ProductId; row.Cells[1].Value = mod.ProductName; row.Cells[2].Value = mod.Barcode; row.Cells[3].Value = mod.UnitNo; row.Cells[4].Value = 1; row.Cells[5].Value = dalprice.GetDefaultPrice(mod.ProductId, out Util.emsg); row.Cells[6].Value = decimal.Parse(row.Cells[5].Value.ToString()); row.Cells[8].Value = mod.Specify; DBGrid.Rows.Add(row); row.Dispose(); SumData(); } else { MessageBox.Show("没有找到商品!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); } } if (DBGrid.RowCount > 0) { DBGrid.CurrentCell = DBGrid.Rows[DBGrid.RowCount - 1].Cells[4]; } txtProduct.Text = string.Empty; txtProduct.Focus(); } }
private void toolExport_Click(object sender, EventArgs e) { if (DBGrid.CurrentRow == null) { return; } frmSingleSelect frm = new frmSingleSelect(); frm.InitData("请选择导出单据类别:", "送货单,购销合同", "送货单", ComboBoxStyle.DropDownList); if (frm.ShowDialog() == DialogResult.OK) { IList <modExcelRangeData> list = new List <modExcelRangeData>(); modSalesShipment mod = (modSalesShipment)DBGrid.CurrentRow.DataBoundItem; BindingCollection <modSalesShipmentDetail> listdetail = _dal.GetDetail(mod.ShipId, out Util.emsg); dalCustomerList dalcust = new dalCustomerList(); modCustomerList modcust = dalcust.GetItem(mod.CustId, out Util.emsg); switch (Util.retValue1) { case "送货单": case "收营单": string company = clsLxms.GetParameterValue("COMPANY_NAME"); switch (company) { case "深圳市蓝图净化用品有限公司": list.Add(new modExcelRangeData("№ " + mod.ShipNo, "H6", "I6")); list.Add(new modExcelRangeData(modcust.FullName, "C7", "E7")); list.Add(new modExcelRangeData(modcust.Tel, "G7", "I7")); list.Add(new modExcelRangeData(modcust.Linkman, "C8", "E8")); list.Add(new modExcelRangeData(modcust.Fax, "G8", "I8")); list.Add(new modExcelRangeData(mod.ShipAddr, "C9", "I9")); list.Add(new modExcelRangeData(mod.CustOrderNo, "A13", "C13")); list.Add(new modExcelRangeData(modcust.PayMethod, "D13", "E13")); dalAdminEmployeeList dalemp = new dalAdminEmployeeList(); modAdminEmployeeList modemp = dalemp.GetItem(mod.SalesMan, out Util.emsg); if (modemp != null) { list.Add(new modExcelRangeData(modemp.EmployeeName, "F13", "F13")); } else { list.Add(new modExcelRangeData(mod.SalesMan, "F13", "F13")); } list.Add(new modExcelRangeData(mod.ShipDate.ToString("yyyy年MM月dd日"), "G13", "G13")); for (int i = 0; i < listdetail.Count; i++) { modSalesShipmentDetail modd = listdetail[i]; string col = (17 + i).ToString().Trim(); list.Add(new modExcelRangeData((i + 1).ToString(), "A" + col, "A" + col)); list.Add(new modExcelRangeData(modd.ProductName, "B" + col, "C" + col)); list.Add(new modExcelRangeData(modd.Specify, "D" + col, "D" + col)); list.Add(new modExcelRangeData(modd.Qty.ToString(), "E" + col, "E" + col)); list.Add(new modExcelRangeData(modd.UnitNo, "F" + col, "F" + col)); list.Add(new modExcelRangeData(modd.Price.ToString("#,##0.00"), "G" + col, "G" + col)); list.Add(new modExcelRangeData((modd.Qty * modd.Price).ToString("#,##0.00"), "H" + col, "H" + col)); list.Add(new modExcelRangeData(modd.Remark, "I" + col, "I" + col)); } clsExport.ExportByTemplate(list, "蓝图送货单", 1, 24, 10, 1); break; default: list.Add(new modExcelRangeData(clsLxms.GetParameterValue("COMPANY_NAME"), "A1", "L1")); list.Add(new modExcelRangeData("TEL:" + clsLxms.GetParameterValue("COMPANY_TEL") + " Fax:" + clsLxms.GetParameterValue("COMPANY_FAX"), "A2", "L2")); list.Add(new modExcelRangeData("公司地址:" + clsLxms.GetParameterValue("COMPANY_ADDR"), "A3", "L3")); if (mod.InvoiceStatus >= 1) { list.Add(new modExcelRangeData("S", "L4", "L4")); } list.Add(new modExcelRangeData(mod.ShipType, "E4", "I5")); list.Add(new modExcelRangeData(mod.CustOrderNo, "C4", "D4")); list.Add(new modExcelRangeData(modcust.FullName, "C5", "D5")); list.Add(new modExcelRangeData(mod.ShipAddr, "C6", "D6")); list.Add(new modExcelRangeData(modcust.Linkman + " " + modcust.Tel, "K4", "K4")); list.Add(new modExcelRangeData(mod.ShipNo, "K5", "K5")); list.Add(new modExcelRangeData(mod.ShipDate.ToString("yyyy年MM月dd日"), "K6", "K6")); list.Add(new modExcelRangeData("合计金额:" + clsMoney.ConvertToMoney(Convert.ToDouble(mod.DetailSum + mod.OtherMny - mod.KillMny)), "A16", "I17")); list.Add(new modExcelRangeData(string.Format("{0:C2}", mod.DetailSum + mod.OtherMny - mod.KillMny), "J16", "K16")); list.Add(new modExcelRangeData("付款方式:" + mod.PayMethod, "J17", "K17")); list.Add(new modExcelRangeData(Util.UserName, "K20", "K20")); for (int i = 0; i < listdetail.Count; i++) { modSalesShipmentDetail modd = listdetail[i]; string col = (8 + i).ToString().Trim(); list.Add(new modExcelRangeData((i + 1).ToString(), "A" + col, "A" + col)); list.Add(new modExcelRangeData(modd.ProductName, "B" + col, "D" + col)); list.Add(new modExcelRangeData(modd.UnitNo, "E" + col, "E" + col)); list.Add(new modExcelRangeData(modd.Qty.ToString(), "F" + col, "G" + col)); list.Add(new modExcelRangeData(string.Format("{0:C2}", modd.Price), "H" + col, "I" + col)); list.Add(new modExcelRangeData(string.Format("{0:C2}", modd.Qty * modd.Price), "J" + col, "J" + col)); list.Add(new modExcelRangeData(modd.Remark, "K" + col, "K" + col)); } clsExport.ExportByTemplate(list, "送货单", 1, 20, 11, 1); break; } break; case "购销合同": list.Add(new modExcelRangeData(modcust.FullName, "B6", "E6")); list.Add(new modExcelRangeData(mod.ShipNo, "I6", "I6")); list.Add(new modExcelRangeData(mod.ShipDate.ToString("yyyy年MM月dd日"), "I7", "I7")); list.Add(new modExcelRangeData("金额大写:" + clsMoney.ConvertToMoney(Convert.ToDouble(mod.DetailSum + mod.OtherMny - mod.KillMny)), "A23", "I23")); list.Add(new modExcelRangeData(string.Format("{0:C2}", mod.DetailSum + mod.OtherMny - mod.KillMny), "H22", "H22")); dalProductList dalpdt = new dalProductList(); for (int i = 0; i < listdetail.Count; i++) { modSalesShipmentDetail modd = listdetail[i]; string col = (10 + i).ToString().Trim(); //list.Add(new modExcelRangeData((i+1).ToString(), "A" + col, "A" + col)); list.Add(new modExcelRangeData(modd.ProductName, "B" + col, "B" + col)); modProductList modpdt = dalpdt.GetItem(modd.ProductId, out Util.emsg); if (modpdt != null) { list.Add(new modExcelRangeData(modpdt.Brand, "C" + col, "C" + col)); } list.Add(new modExcelRangeData(modd.Qty.ToString(), "D" + col, "D" + col)); list.Add(new modExcelRangeData(modd.UnitNo, "E" + col, "E" + col)); list.Add(new modExcelRangeData(string.Format("{0:C2}", modd.Price), "G" + col, "G" + col)); list.Add(new modExcelRangeData(string.Format("{0:C2}", modd.Qty * modd.Price), "H" + col, "H" + col)); list.Add(new modExcelRangeData(modd.Remark, "I" + col, "I" + col)); } clsExport.ExportByTemplate(list, "购销合同", 1, 38, 9, 1); break; } } }