//private void cmbGoodsName_DrawItem(object sender, DrawItemEventArgs e) //{ // if (e.Index < 0) // { // return; // } // e.DrawBackground(); // e.DrawFocusRectangle(); // e.Graphics.DrawString(cmbGoodsName.GetItemText(cmbGoodsName.Items[e.Index]).ToString(), e.Font, new SolidBrush(e.ForeColor), e.Bounds.X, e.Bounds.Y + 0); //} private void frmWorkShopWeightList_Load(object sender, EventArgs e) { List <string> insertList = new List <string>(); MesInventoryBLL InventoryBLL = new MesInventoryBLL(); this.listView1.Items.Clear(); this.listView1.BeginUpdate(); var Scan_rows = InventoryBLL.GetData(" where I_StockCode = '" + Globels.strStockCode + "' and I_Qty > 0 order by I_GoodsCode"); for (int i = 0; i < Scan_rows.Count; i++) { string strGoodsCode = Scan_rows[i].I_GoodsCode; Mes_ConvertBLL ConvertBLL = new Mes_ConvertBLL(); var Convert_rows = ConvertBLL.GetList_Mes_Convert(" where C_Code = '" + strGoodsCode + "' and C_ProNo = '" + Globels.strProce + "' order by C_SecName"); for (int j = 0; j < Convert_rows.Count; j++) { if (!insertList.Contains(Convert_rows[j].C_SecName)) { insertList.Add(Convert_rows[j].C_SecName); ListViewItem lvi = new ListViewItem(Convert_rows[j].C_SecName); this.listView1.Items.Add(lvi); } //if (!cmbGoodsName.Items.Contains(Convert_rows[j].C_SecName)) //{ // cmbGoodsName.Items.Add(Convert_rows[j].C_SecName); //} } } this.listView1.EndUpdate(); }
private void cmbStock_SelectedIndexChanged(object sender, EventArgs e) { MesStockBLL StockBLL = new MesStockBLL(); var row = StockBLL.GetData(" where S_Code = '" + cmbStock.Text + "'"); cmbStockName.Text = row[0].S_Name; cmbGoodsCode.Items.Clear(); cmbGoodsName.Items.Clear(); MesInventoryBLL InventoryBLL = new MesInventoryBLL(); var row2 = InventoryBLL.GetData("where I_StockCode = '" + cmbStock.Text + "' and I_Qty > 0 "); for (int i = 0; i < row2.Count; i++) { if (!cmbGoodsCode.Items.Contains(row2[i].I_GoodsCode)) { cmbGoodsCode.Items.Add(row2[i].I_GoodsCode); } if (!cmbGoodsName.Items.Contains(row2[i].I_GoodsName)) { cmbGoodsName.Items.Add(row2[i].I_GoodsName); } } if (row2.Count == 1) { cmbGoodsCode.Text = row2[0].I_GoodsCode; cmbGoodsName.Text = row2[0].I_GoodsName; } }
private void cmbGoodsName_SelectedIndexChanged(object sender, EventArgs e) { MesInventoryBLL InventoryBLL = new MesInventoryBLL(); var row2 = InventoryBLL.GetData("where I_StockCode = '" + cmbStock.Text + "' and I_GoodsName = '" + cmbGoodsName.Text + "' and I_Qty > 0 "); cmbGoodsCode.Text = row2[0].I_GoodsCode; }
private void cmbBatch_SelectedIndexChanged(object sender, EventArgs e) { MesInventoryBLL InventoryBLL = new MesInventoryBLL(); var row = InventoryBLL.GetData(" where I_StockCode = '" + cmbStock.Text + "' and I_GoodsName = '" + cmbGoodsName.Text + "' and I_Batch = '" + cmbBatch.Text + "' and I_Qty > 0"); if (row.Count > 0) { txtQty.Text = row[0].I_Qty.ToString(); //MesInventoryBLL } }
private void cmbGoodsCode_SelectedIndexChanged(object sender, EventArgs e) { try { cmbBatch.Items.Clear(); MesInventoryBLL InventoryBLL = new MesInventoryBLL(); var row = InventoryBLL.GetData("where I_StockCode = '" + cmbStock.Text + "' and I_GoodsCode = '" + cmbGoodsCode.Text + "' and I_Qty > 0"); for (int i = 0; i < row.Count; i++) { cmbBatch.Items.Add(row[i].I_Batch); } if (row.Count == 1) { cmbBatch.Text = row[0].I_Batch; txtQty.Text = row[0].I_Qty.ToString(); } MesGoodsBLL GoodsBLL = new MesGoodsBLL(); var Goods_rows = GoodsBLL.GetList(cmbGoodsCode.Text, ""); int nLen = Goods_rows.Count; if (nLen > 0) { cmbGoodsName.Text = Goods_rows[0].G_Name; txtUnit.Text = Goods_rows[0].G_Unit.ToString(); dPrice = Goods_rows[0].G_Price; //int nKind = Goods_rows[0].G_Kind; //if (nKind == 1) //{ // label17.Visible = true; // cmbSupplyName.Visible = true; //} //else //{ // ; //} } } catch (Exception ex) { //lblTS.Text = "ex.ToString()"; } }
private void frmWorkShopScanList_Load(object sender, EventArgs e) { cmbGoodsCode.Items.Clear(); MesInventoryBLL InventoryBLL = new MesInventoryBLL(); var row2 = InventoryBLL.GetData("where I_StockCode = '" + Globels.strStockCode + "' and I_Qty > 0 "); for (int i = 0; i < row2.Count; i++) { cmbGoodsCode.Items.Add(row2[i].I_GoodsCode); } if (row2.Count == 1) { cmbGoodsCode.Text = row2[0].I_GoodsCode; } txtBarcode.Focus(); }
private void btn_Search_Click(object sender, EventArgs e) { MesInventoryBLL InventoryBLL = new MesInventoryBLL(); DataSet ds = InventoryBLL.GetData2("select SUM(I_Qty) as qty,I_GoodsCode,I_GoodsName,I_Unit from Mes_Inventory where I_StockCode = '" + cmbStock.Text + "' and I_Qty > 0 group by I_GoodsCode,I_GoodsName,I_Unit"); this.listView1.Items.Clear(); Thread.Sleep(100); this.listView1.BeginUpdate(); int nLen = ds.Tables[0].Rows.Count; for (int i = 0; i < nLen; i++) { ListViewItem lvi = new ListViewItem(cmbStock.Text); lvi.SubItems.Add(cmbStockName.Text); lvi.SubItems.Add(ds.Tables[0].Rows[i]["I_GoodsCode"].ToString()); lvi.SubItems.Add(ds.Tables[0].Rows[i]["I_GoodsName"].ToString()); lvi.SubItems.Add(ds.Tables[0].Rows[i]["qty"].ToString()); lvi.SubItems.Add(ds.Tables[0].Rows[i]["I_Unit"].ToString()); this.listView1.Items.Add(lvi); } this.listView1.EndUpdate(); }
private void btn_Convet_Click(object sender, EventArgs e) { try { List <string> Goods = new List <string>(); List <string> strOldGoods = new List <string>(); int nKind = 0; //计算有几种原物料 int nLen = dataGridView1.Rows.Count; string strStockName = ""; string strStockCode = ""; for (int i = 0; i < nLen - 1; i++) { object obj = dataGridView1.Rows[i].Cells["选择"].Value; //if (Convert.ToString(obj) == "True" || Convert.ToString(obj) == "1") //{ string strGoods = dataGridView1.Rows[i].Cells["物料"].Value.ToString(); string strQty = dataGridView1.Rows[i].Cells["实用数量"].Value.ToString(); string strYLQty = dataGridView1.Rows[i].Cells["数量"].Value.ToString(); strStockCode = dataGridView1.Rows[i].Cells["仓库编码"].Value.ToString(); strStockName = dataGridView1.Rows[i].Cells["仓库名称"].Value.ToString(); //string strPc = dataGridView1.Rows[i].Cells["批次"].Value.ToString(); string strPrice = dataGridView1.Rows[i].Cells["价格"].Value.ToString(); string strName = dataGridView1.Rows[i].Cells["物料名称"].Value.ToString(); string strUnit = dataGridView1.Rows[i].Cells["单位"].Value.ToString(); if (Convert.ToDecimal(strQty) > Convert.ToDecimal(strYLQty)) { lblTS.Text = "系统提示:物料:" + strName + "实用数量不能大于库存数量"; return; } if (Convert.ToDecimal(strQty) == 0 || Convert.ToDecimal(strQty) < 0) { lblTS.Text = "系统提示:物料:" + strName + "实用数量不能为0或者负数"; return; } if (Jud(strGoods, txtGoodsCode.Text)) { if (strOldGoods.Contains(strGoods)) { } else { nKind = nKind + 1; strOldGoods.Add(strGoods); } bool bRet = false; for (int j = 0; j < Goods.Count; j++) { string strTemp = Goods[j].ToString(); string[] str = strTemp.Split(','); string strTempGoods = str[0].ToString(); string strTempPc = str[2].ToString(); string strTempQty = str[3].ToString(); if (strTempGoods == strGoods) { decimal dQty = Convert.ToDecimal(strQty) + Convert.ToDecimal(strTempQty); Goods[j] = strGoods + "," + dQty.ToString() + "," + strPrice + "," + strName + "," + strUnit; bRet = true; } } if (bRet == false) { Goods.Add(strGoods + "," + strQty + "," + strPrice + "," + strName + "," + strUnit); } //} else { lblTS.Text = "系统提示:选择的物料生成不了下一个物料,请核对"; return; } } } if (!Jud2(nKind, txtGoodsCode.Text)) { lblTS.Text = "系统提示:选择的转换前的物料不够"; return; } Mes_OrgResHeadBLL OrgResHeadBLL = new Mes_OrgResHeadBLL(); Mes_OrgResDetailBLL OrgResDetailBLL = new Mes_OrgResDetailBLL(); Mes_OrgResHeadEntity OrgResHeadEntity = new Mes_OrgResHeadEntity(); Mes_OrgResDetailEntity OrgResDetailEntity = new Mes_OrgResDetailEntity(); string strIn_No = ""; MesMaterInHeadBLL MaterInHeadBLL = new MesMaterInHeadBLL(); strIn_No = MaterInHeadBLL.GetDH("组装与拆分单"); OrgResHeadEntity.O_OrgResNo = strIn_No; OrgResHeadEntity.O_OrderNo = ""; OrgResHeadEntity.O_CreateBy = Globels.strUser; OrgResHeadEntity.O_CreateDate = DateTime.Now; OrgResHeadEntity.O_OrderDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); OrgResHeadEntity.O_Remark = ""; OrgResHeadEntity.O_Status = 1; OrgResHeadEntity.O_StockCode = strStockCode; OrgResHeadEntity.O_StockName = strStockName; OrgResHeadEntity.O_WorkShopCode = Globels.strWorkShop; OrgResHeadEntity.O_WorkShopName = Globels.strWorkShopName; OrgResHeadEntity.O_Record = ""; OrgResHeadEntity.O_ProCode = Globels.strProce; OrgResHeadEntity.O_TeamCode = Globels.strTeam; OrgResHeadEntity.O_TeamName = Globels.strTeamName; int nRow = OrgResHeadBLL.SaveEntity("", OrgResHeadEntity); decimal dSecPrice = 0; decimal dTotal = 0; for (int i = 0; i < Goods.Count; i++) { string[] strTemp = Goods[i].ToString().Split(','); dTotal = dTotal + (Convert.ToDecimal(strTemp[2].ToString()) * Convert.ToDecimal(strTemp[1].ToString())); } dSecPrice = dTotal / Convert.ToDecimal(txtQty.Text); for (int i = 0; i < Goods.Count; i++) { OrgResDetailEntity.O_OrgResNo = strIn_No; OrgResDetailEntity.O_SecGoodsCode = txtGoodsCode.Text; OrgResDetailEntity.O_SecGoodsName = txtGoodsName.Text; OrgResDetailEntity.O_SecPrice = 0; OrgResDetailEntity.O_SecQty = Convert.ToDecimal(txtQty.Text); OrgResDetailEntity.O_SecUnit = m_strUnit; OrgResDetailEntity.O_SecBatch = txtPc.Text; string[] strTemp = Goods[i].ToString().Split(','); string strGoodsCode = strTemp[0].ToString(); //Mes_ConvertBLL ConvertBLL = new Mes_ConvertBLL(); //var Convert_rows = ConvertBLL.GetList_Mes_Convert(" where C_SecCode = '" + strGoodsCode + "'"); //string strC_GoodsCode = ""; //if (Convert_rows.Count > 0) //{ // strC_GoodsCode = Convert_rows[0].C_Code; //} MesInventoryBLL InventoryBLL = new MesInventoryBLL(); var Inventory_row = InventoryBLL.GetData(" where I_StockCode = '" + Globels.strStockCode + "' and I_GoodsCode = '" + strGoodsCode + "' and I_Qty > 0 order by I_Batch"); if (Inventory_row.Count > 0) { Decimal dTotalQty = Convert.ToDecimal(strTemp[1].ToString()); for (int j = 0; j < Inventory_row.Count; j++) { if (dTotalQty > 0) { if (dTotalQty < Inventory_row[j].I_Qty) { OrgResDetailEntity.O_GoodsCode = strTemp[0].ToString(); OrgResDetailEntity.O_GoodsName = strTemp[3].ToString(); OrgResDetailEntity.O_Price = Convert.ToDecimal(strTemp[2].ToString()); OrgResDetailEntity.O_Qty = dTotalQty; OrgResDetailEntity.O_Unit = strTemp[4].ToString(); OrgResDetailEntity.O_Batch = Inventory_row[j].I_Batch; OrgResDetailEntity.O_SecPrice = dSecPrice; nRow = OrgResDetailBLL.SaveEntity("", OrgResDetailEntity); //UpdateData(Inventory_row[j].ID, Inventory_row[j].I_Qty - dTotalQty); break; } else { OrgResDetailEntity.O_GoodsCode = strTemp[0].ToString(); OrgResDetailEntity.O_GoodsName = strTemp[3].ToString(); OrgResDetailEntity.O_Price = Convert.ToDecimal(strTemp[2].ToString()); OrgResDetailEntity.O_Qty = Inventory_row[j].I_Qty; OrgResDetailEntity.O_Unit = strTemp[4].ToString(); OrgResDetailEntity.O_Batch = Inventory_row[j].I_Batch; OrgResDetailEntity.O_SecPrice = dSecPrice; nRow = OrgResDetailBLL.SaveEntity("", OrgResDetailEntity); dTotalQty = dTotalQty - Inventory_row[j].I_Qty; //DeleteData(Inventory_row[j].ID); } } } } //OrgResDetailEntity.O_GoodsCode = strTemp[0].ToString(); //OrgResDetailEntity.O_GoodsName = strTemp[4].ToString(); //OrgResDetailEntity.O_Price = Convert.ToDecimal(strTemp[3].ToString()); //OrgResDetailEntity.O_Qty = Convert.ToDecimal(strTemp[1].ToString()); //OrgResDetailEntity.O_Unit = strTemp[5].ToString(); //OrgResDetailEntity.O_Batch = strTemp[2].ToString(); //OrgResDetailEntity.O_SecPrice = dSecPrice; //nRow = OrgResDetailBLL.SaveEntity("", OrgResDetailEntity); } Upload(strIn_No); MessageBox.Show("保存成功"); lblTS.Text = ""; //UpdatePrice(strSecGoods, dSecPrice); 已经在存储过程中处理 Delete(); //Update(); this.Close(); } catch (Exception ex) { lblTS.Text = ex.ToString(); return; } }