private void Datagrid2_ItemCommand(object source, DataGridCommandEventArgs e) { if (e.CommandName == "SelectEnter") { if (e.Item.Cells[15].Text.Trim() == "" || e.Item.Cells[15].Text.Trim() == " ") { this.Popup("请填写生产日期!"); return; } if (e.Item.Cells[17].Text.Trim() == "" || e.Item.Cells[17].Text.Trim() == " ") { this.Popup("请填写过期日期!"); return; } string strWhcode = this.ddlWhouse.SelectedValue; Entity.RdRecordDetail rrd = new RdRecordDetail(); rrd.cnnAutoID = int.Parse(e.Item.Cells[0].Text.Trim()); rrd.cnvcPOID = e.Item.Cells[2].Text.Trim(); rrd.cnnRdID = int.Parse(this.txtRdID.Text.Trim()); rrd.cndMdate = DateTime.Parse(e.Item.Cells[15].Text.Trim()); rrd.cndExpDate = DateTime.Parse(e.Item.Cells[17].Text.Trim()); rrd.cnvcInvCode = e.Item.Cells[4].Text.Trim(); if (strWhcode == "") { this.Popup("仓库不能为空!"); return; } // DataTable dtsum=(DataTable)Session["sumenter"]; // if(dtsum==null||dtsum.Rows.Count<=0) // { // this.Popup("该采购入库单无任何货品记录,请先关联采购订单!"); // return; // } Entity.OperLog ol = new AMSApp.zhenghua.Entity.OperLog(); ol.cnvcOperType = "采购入库单入库"; ol.cnvcOperID = this.oper.strLoginID; ol.cnvcDeptID = this.oper.strDeptID; StorageFacade sto = new StorageFacade(); int ret = sto.PoStockEnterExecEntering(ol, strWhcode, rrd); if (ret > 0) { this.Popup("采购入库单入库成功!"); this.DBBind(); } else { this.Popup("采购入库单入库失败!"); } } }
private void Datagrid2_UpdateCommand(object source, DataGridCommandEventArgs e) { if (((TextBox)e.Item.Cells[11].Controls[0]).Text.Trim() == "" || !this.JudgeIsNum(((TextBox)e.Item.Cells[11].Controls[0]).Text.Trim())) { this.Popup("入库数量不能为空且必须是数字!"); return; } if (((TextBox)e.Item.Cells[10].Controls[0]).Text.Trim() == "" || !this.JudgeIsNum(((TextBox)e.Item.Cells[10].Controls[0]).Text.Trim())) { this.Popup("损耗数量不能为空且必须是数字!"); return; } Entity.RdRecordDetail rrd = new RdRecordDetail(); rrd.cnnAutoID = int.Parse(e.Item.Cells[0].Text.Trim()); rrd.cnnQuantity = Math.Round(decimal.Parse(((TextBox)e.Item.Cells[11].Controls[0]).Text.Trim()), 2); decimal dlostcount = Math.Round(decimal.Parse(((TextBox)e.Item.Cells[10].Controls[0]).Text.Trim()), 2); decimal doutcount = Math.Round(decimal.Parse(e.Item.Cells[9].Text.Trim()), 2); if (rrd.cnnAutoID.ToString() == "" || rrd.cnnAutoID == 0) { this.Popup("分货入库单子表标识不正确!"); return; } if (doutcount != rrd.cnnQuantity + dlostcount) { this.Popup("损耗数量+入库数量不等于分货数量"); return; } Entity.OperLog ol = new AMSApp.zhenghua.Entity.OperLog(); ol.cnvcOperType = "修改分货入库子表"; ol.cnvcOperID = this.oper.strLoginID; ol.cnvcDeptID = this.oper.strDeptID; StorageFacade sto = new StorageFacade(); int ret = sto.UpdateDeptStorageEnterDetail(ol, rrd, dlostcount); if (ret > 0) { this.Popup("修改分货入库单子表明细成功!"); this.DBBind(); } else { this.Popup("修改分货入库单子表明细失败!"); } }
private void Datagrid2_UpdateCommand(object source, DataGridCommandEventArgs e) { decimal EnterQuantity = Math.Round(decimal.Parse(e.Item.Cells[8].Text.Trim()), 2); Entity.RdRecordDetail rrd = new RdRecordDetail(); rrd.cnnAutoID = int.Parse(e.Item.Cells[0].Text.Trim()); rrd.cnnQuantity = Math.Round(decimal.Parse(((TextBox)e.Item.Cells[9].Controls[0]).Text.Trim()), 2); rrd.cnvcCommens = ((TextBox)e.Item.Cells[11].Controls[0]).Text.Trim(); if (rrd.cnnQuantity > EnterQuantity) { this.Popup("采购退货数量不能大于原入库数量!"); return; } if (rrd.cnnAutoID.ToString() == "" || rrd.cnnAutoID == 0) { this.Popup("采购退货单子表标识不正确!"); return; } Entity.OperLog ol = new AMSApp.zhenghua.Entity.OperLog(); ol.cnvcOperType = "修改采购退货子表"; ol.cnvcOperID = this.oper.strLoginID; ol.cnvcDeptID = this.oper.strDeptID; StorageFacade sto = new StorageFacade(); int ret = sto.UpdatePoStockReturnDetail(ol, rrd); if (ret > 0) { this.Popup("修改采购退货单子表明细成功!"); this.DBBind(); } else { this.Popup("修改采购退货单子表明细失败!"); } }
public void AssignOut(string strProduceSerialNo, OperLog operLog, string strWarehouse) { using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { string strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString(); DateTime dtSysTime = DateTime.Parse(strSysTime); string strsql1 = "SELECT * FROM tbProduceLog WHERE cnvcProduceState='6' and cnnProduceSerialNo=" + strProduceSerialNo; DataTable dtProduceLog = SqlHelper.ExecuteDataTable(trans, CommandType.Text, strsql1); //rr.cndMakeDate = dtSysTime; //EntityMapping.Create(rr,trans); if (dtProduceLog.Rows.Count == 0) { throw new Exception("生产计划不在分货状态!"); } Entity.ProduceLog pl = new ProduceLog(dtProduceLog); string strsql2 = "select * from tbproducechecklog WHERE cnnAssignCount>0 and cnnproduceserialno=" + strProduceSerialNo; DataTable dtProduceCheckLog = SqlHelper.ExecuteDataTable(trans, CommandType.Text, strsql2); if (dtProduceCheckLog.Rows.Count == 0) { throw new Exception("分货出库产品数量都为0"); } DataTable dtInv = SingleTableQuery.ExcuteQuery("tbInventory", trans); DataTable dtComputationUnit = SingleTableQuery.ExcuteQuery("tbComputationUnit", trans); string strsql3 = "select * from tbassignlog where cnnproduceserialno=" + strProduceSerialNo; DataTable dtAssignLog = SqlHelper.ExecuteDataTable(trans, CommandType.Text, strsql3); if (dtAssignLog.Rows.Count == 0) { throw new Exception("未找到分货流水"); } Entity.AssignLog al = new AssignLog(dtAssignLog); Entity.RdRecord rr = new RdRecord(); rr.cnvcRdCode = "RD010"; rr.cnvcRdFlag = "0"; rr.cnvcWhCode = strWarehouse; rr.cnvcDepID = pl.cnvcProduceDeptID; //rr.cnvcOperName = operLog.cnvcop rr.cnvcComments = "分货出库"; rr.cnvcMaker = operLog.cnvcOperID; rr.cnnProorderID = pl.cnnProduceSerialNo; rr.cnvcState = "2"; rr.cndMakeDate = dtSysTime; long rrid = EntityMapping.Create(rr, trans); foreach (DataRow drProduceCheckLog in dtProduceCheckLog.Rows) { Entity.ProduceCheckLog pcl = new ProduceCheckLog(drProduceCheckLog); Entity.RdRecordDetail rrd = new RdRecordDetail(); rrd.cnvcFlag = "0"; rrd.cndExpDate = pcl.cndExpDate; //Convert.ToDateTime(this.txtProduceDate.Text).AddDays(pc.cnnDays).AddDays(Convert.ToDouble(txtDays.Text));//Convert.ToDateTime(this.txtExpDate.Text); rrd.cndMdate = pcl.cndMDate; //Convert.ToDateTime(this.txtProduceDate.Text); rrd.cnnRdID = Convert.ToDecimal(rrid); rrd.cnvcPOID = al.cnnAssignSerialNo.ToString(); DataRow[] drinvs = dtInv.Select("cnvcInvCode='" + pcl.cnvcInvCode + "'"); if (drinvs.Length == 0) { throw new Exception(pcl.cnvcInvCode + "存货档案未设置"); } Entity.Inventory inv = new AMSApp.zhenghua.Entity.Inventory(drinvs[0]); rrd.cnvcInvCode = inv.cnvcInvCode; rrd.cnvcGroupCode = inv.cnvcGroupCode; rrd.cnvcComunitCode = inv.cnvcSTComUnitCode; DataRow[] drcus = dtComputationUnit.Select("cnvcGroupCode='" + inv.cnvcGroupCode + "' and cnbMainUnit=1"); if (drcus.Length == 0) { throw new Exception(inv.cnvcGroupCode + "未设置主计量单位"); } decimal dchangerate = Convert.ToDecimal(drcus[0]["cnichangrate"].ToString()); DataRow[] drcus1 = dtComputationUnit.Select("cnvcGroupCode='" + inv.cnvcGroupCode + "' and cnvcComUnitCode='" + inv.cnvcSTComUnitCode + "'"); decimal dchangerate_st = Convert.ToDecimal(drcus1[0]["cnichangrate"].ToString()); // string strcssql = "SELECT * FROM tbCurrentStock WHERE cnvcWhCode='"+strWarehouse+"' AND cnvcInvCode='"+pcl.cnvcInvCode+"'"; // DataTable dtcs = SqlHelper.ExecuteDataTable(trans,CommandType.Text,strcssql); string strcssql = "SELECT * FROM tbCurrentStock WHERE cnvcWhCode='" + strWarehouse + "' AND cnvcInvCode='" + pcl.cnvcInvCode + "'" + " and CONVERT(char(10),isnull(cndExpDate,''),121)>=CONVERT(char(10),getdate(),121) "; string strcssql2 = "SELECT isnull(sum(cnnAvaQuantity),0) FROM tbCurrentStock WHERE cnvcWhCode='" + strWarehouse + "' AND cnvcInvCode='" + pcl.cnvcInvCode + "'" + " and CONVERT(char(10),isnull(cndExpDate,''),121)>=CONVERT(char(10),getdate(),121) "; DataTable dtcs = SqlHelper.ExecuteDataTable(trans, CommandType.Text, strcssql); decimal davaquantity = Convert.ToDecimal(SqlHelper.ExecuteScalar(trans, CommandType.Text, strcssql2).ToString()); if (dtcs.Rows.Count == 0) { throw new Exception(pcl.cnvcInvCode + "无库存"); } if (davaquantity - pcl.cnnAssignCount * dchangerate_st / dchangerate < 0) { throw new Exception(pcl.cnvcInvCode + "库存不足"); } // if(cs.cnnAvaQuantity - pcl.cnnAssignCount<0) // throw new Exception(pcl.cnvcInvCode+"库存不足"); decimal dhave = 0; foreach (DataRow drcs in dtcs.Rows) { Entity.CurrentStock cs = new CurrentStock(drcs); // if(cs.cnnAvaQuantity - pcl.cnnAssignCount<0) // throw new Exception(pcl.cnvcInvCode+"库存不足"); // cs.cnnAvaQuantity = cs.cnnAvaQuantity - pcl.cnnAssignCount; // cs.cnnQuantity = cs.cnnQuantity - pcl.cnnAssignCount; // EntityMapping.Update(cs,trans); if (cs.cnnAvaQuantity > pcl.cnnAssignCount * dchangerate_st / dchangerate - dhave) { cs.cnnAvaQuantity = cs.cnnAvaQuantity - pcl.cnnAssignCount * dchangerate_st / dchangerate; cs.cnnQuantity = cs.cnnQuantity - pcl.cnnAssignCount * dchangerate_st / dchangerate; EntityMapping.Update(cs, trans); break; } else { cs.cnnAvaQuantity = 0; cs.cnnQuantity = 0; EntityMapping.Update(cs, trans); dhave += cs.cnnAvaQuantity; } } rrd.cnnQuantity = pcl.cnnAssignCount * dchangerate_st / dchangerate; EntityMapping.Create(rrd, trans); } //string strsql = "update tbMakeDetail set cnbCollar=1 where cnnMakeSerialNo="+strMakeSerialNo; //SqlHelper.ExecuteNonQuery(trans,CommandType.Text,strsql); string strsql4 = "update tbproducelog set cnvcproducestate='7' where cnnproduceserialno=" + strProduceSerialNo; SqlHelper.ExecuteNonQuery(trans, CommandType.Text, strsql4); operLog.cndOperDate = dtSysTime; operLog.cnvcComments = "生产流水:" + strProduceSerialNo; EntityMapping.Create(operLog, trans); trans.Commit(); } catch (SqlException sex) { trans.Rollback(); LogAdapter.WriteDatabaseException(sex); throw sex; } catch (Exception ex) { trans.Rollback(); LogAdapter.WriteFeaturesException(ex); throw ex; } finally { ConnectionPool.ReturnConnection(conn); } } }
private void btnCheck_Click(object sender, System.EventArgs e) { if (Session["tbProduceDetail"] == null) { this.Popup("请首先使用【盘点清单】按钮,查询计划情况"); return; } if (this.JudgeIsNull(txtDays.Text)) { this.Popup("请输入过期天数调整量"); return; } DataTable dtpd = (DataTable)Session["tbProduceDetail"]; ArrayList al = new ArrayList(); DataTable dtInv = Application["tbInventory"] as DataTable; DataTable dtProductClass = Application["tbProductClass"] as DataTable; // string strSql = "select * from tbProduceCheckLog where cnnProduceSerialNo=" + txtProduceSerialNo.Text+" order by cnvcInvCode"; // DataTable dtCheck = Helper.Query(strSql); //foreach(DataGridItem dgi in this.DataGrid1.Items) foreach (DataRow dr in dtpd.Rows) { //Entity.ProduceCheckLog pc = new ProduceCheckLog(dr); string strinvcode = dr["cnvcInvCode"].ToString(); //dgi.Cells[0].Text; string strinvname = dr["cnvcInvName"].ToString(); //dgi.Cells[1].Text; string strincount = dr["cnnInCount"].ToString(); //dgi.Cells[6].Text; //string strwhcount = dgi.Cells[7].Text; bool iswh = Convert.ToBoolean(dr["cnbInWh"].ToString()); //((CheckBox)dgi.Cells[7].Controls[1]).Checked; if (iswh) { this.Popup("已经完成了盘点入库"); return; } decimal dincount = Convert.ToDecimal(strincount); Entity.RdRecordDetail rrd = new RdRecordDetail(); rrd.cnvcInvCode = strinvcode; rrd.cnnQuantity = Convert.ToDecimal(strincount); DataRow[] drInvs = dtInv.Select("cnvcInvCode='" + strinvcode + "'"); if (drInvs.Length == 0) { this.Popup(strinvname + "存货档案未找到"); return; } Entity.Inventory inv = new AMSApp.zhenghua.Entity.Inventory(drInvs[0]); DataRow[] drProductClasses = dtProductClass.Select("cnvcProductClassCode='" + inv.cnvcInvCCode + "'"); if (drProductClasses.Length == 0) { this.Popup(strinvname + "的存货类别未找到"); return; } Entity.ProductClass pc = new ProductClass(drProductClasses[0]); rrd.cnvcGroupCode = inv.cnvcGroupCode; rrd.cnvcComunitCode = inv.cnvcSTComUnitCode; rrd.cnvcFlag = "0"; rrd.cndExpDate = Convert.ToDateTime(this.txtProduceDate.Text).AddDays(pc.cnnDays).AddDays(Convert.ToDouble(txtDays.Text)); //Convert.ToDateTime(this.txtExpDate.Text); rrd.cndMdate = Convert.ToDateTime(this.txtProduceDate.Text); //if(rrd.cnnQuantity == 0)continue; al.Add(rrd); } if (al.Count == 0) { this.Popup("无入库产品,不用生产入库!"); return; } Entity.RdRecord rr = new RdRecord(); rr.cnvcRdCode = "RD009"; rr.cnvcRdFlag = "0"; rr.cnvcWhCode = this.ddlWarehouse.SelectedValue; rr.cnvcDepID = this.ddlProduceDept.SelectedValue; rr.cnvcOperName = this.oper.strOperName; rr.cnvcComments = "生产入库"; rr.cnvcMaker = this.oper.strLoginID; rr.cnnProorderID = Convert.ToDecimal(this.txtProduceSerialNo.Text); rr.cnvcState = "2"; OperLog ol = new OperLog(); ol.cnvcOperID = this.oper.strLoginID; ol.cnvcDeptID = this.oper.strDeptID; ol.cnvcOperType = "生产入库"; string strWarehouse = this.ddlWarehouse.SelectedValue; try { ProduceFacade pf = new ProduceFacade(); pf.CheckInWh(this.txtMakeSerialNo.Text, rr, al, ol, strWarehouse); this.Popup("生产入库成功"); } catch (Exception ex) { this.Popup(ex.Message); } QueryProduceDetail(); BindGrid(); }
private void Datagrid2_UpdateCommand(object source, DataGridCommandEventArgs e) { string strRdCode = this.ddlRdCode.SelectedValue; if (strRdCode == "") { this.SetErrorMsgPageBydir("调拨单据信息不全,请重试!"); return; } string stroutcount = "0"; string strLostcount = "0"; string strrealcount = "0"; decimal dlostcount = 0; Entity.RdRecordDetail rrd = new RdRecordDetail(); if (strRdCode == "RD006") { stroutcount = e.Item.Cells[5].Text.Trim(); strLostcount = ((TextBox)e.Item.Cells[6].Controls[0]).Text.Trim(); strrealcount = ((TextBox)e.Item.Cells[7].Controls[0]).Text.Trim(); if (strLostcount == "" || !this.JudgeIsNum(strLostcount)) { this.Popup("损耗数量不能为空且必须是数字!"); return; } if (strrealcount == "" || !this.JudgeIsNum(strrealcount)) { this.Popup("入库数量不能为空且必须是数字!"); return; } string strRate = Helper.Query("select cniChangRate from tbComputationUnit where cnvcComunitCode=(select cnvcSTComunitCode from tbInventory where cnvcInvCode='" + e.Item.Cells[1].Text.Trim() + "')").Rows[0]["cniChangRate"].ToString(); decimal doutcount = Math.Round(decimal.Parse(stroutcount) * decimal.Parse(strRate), 2); dlostcount = Math.Round(decimal.Parse(strLostcount) * decimal.Parse(strRate), 2); decimal drealcount = Math.Round(decimal.Parse(strrealcount) * decimal.Parse(strRate), 2); if (doutcount != drealcount + dlostcount) { this.Popup("损耗数量+入库数量不等于出库数量"); return; } rrd.cnnRdID = int.Parse(e.Item.Cells[0].Text.Trim()); rrd.cnvcInvCode = e.Item.Cells[1].Text.Trim(); rrd.cnnQuantity = Math.Round(decimal.Parse(strrealcount), 2); if (rrd.cnnRdID.ToString() == "" || rrd.cnnRdID == 0) { this.Popup("调拨单标识不正确!"); return; } } Entity.OperLog ol = new AMSApp.zhenghua.Entity.OperLog(); ol.cnvcOperType = "修改调拨单子表"; ol.cnvcOperID = this.oper.strLoginID; ol.cnvcDeptID = this.oper.strDeptID; StorageFacade sto = new StorageFacade(); int ret = sto.UpdateRdRecordMoveDetail(strRdCode, ol, rrd, strLostcount); if (ret > 0) { this.Popup("修改调拨单子表明细成功!"); this.DBBind(); } else { this.Popup("修改调拨单子表明细失败!"); } }
private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e) { if (this.txtMoveCount.Text.Trim() == "" || !this.JudgeIsNum(this.txtMoveCount.Text.Trim())) { this.Popup("调拨数量不能为空且必须是数字!"); return; } DataGridItem item = this.DataGrid1.SelectedItem; decimal dmovecount = Math.Round(decimal.Parse(this.txtMoveCount.Text.Trim()), 2); decimal dmovecountCom = Math.Round(decimal.Parse(this.txtMoveCount.Text.Trim()), 2); DataTable dtrate = Helper.Query("select cniChangRate from tbComputationUnit where cnvcComunitCode='" + item.Cells[4].Text.Trim() + "'"); if (dtrate.Rows.Count == 0) { this.Popup("单位换算率不存在,请检查单位组配置!"); return; } else { dmovecountCom = Math.Round(dmovecountCom * decimal.Parse(dtrate.Rows[0]["cniChangRate"].ToString()), 2); } DataTable dtcount = Helper.Query("select sum(cnnAvaQuantity) as cnnQuantity from tbCurrentStock where cnvcStopFlag='0' and cnvcWhCode='" + this.ddlWhouse.SelectedValue + "' and cnvcInvCode='" + item.Cells[0].Text.Trim() + "'"); if (dtcount == null || dtcount.Rows.Count <= 0) { this.Popup("仓库内无此存货!"); return; } else if (dmovecountCom > Math.Round(decimal.Parse(dtcount.Rows[0]["cnnQuantity"].ToString()), 2)) { this.Popup("仓库内存货数量不足" + dmovecount.ToString() + "!"); return; } ArrayList alrdout = new ArrayList(); ArrayList alrdin = new ArrayList(); decimal dstepcount = 0; decimal dalreadycount = 0; string strRdid = Helper.Query("select cnnRdID from tbRdRecord where cnvcCode='" + this.txtCode.Text.Trim() + "' and cnvcRdCode='RD006'").Rows[0]["cnnRdID"].ToString(); DataTable dtinv = Helper.Query("select cnvcWhCode,cnvcInvCode,cndMdate,cndExpDate,cnnAvaQuantity from tbCurrentStock where cnvcStopFlag='0' and cnvcWhCode='" + this.ddlWhouse.SelectedValue + "' and cnvcInvCode='" + item.Cells[0].Text.Trim() + "' and cnnAvaQuantity>0 order by cndExpDate"); for (int i = 0; i < dtinv.Rows.Count; i++) { dstepcount += Math.Round(decimal.Parse(dtinv.Rows[i]["cnnAvaQuantity"].ToString()), 2); if (dstepcount > dmovecountCom) { RdRecordDetail rdout = new RdRecordDetail(); rdout.cnnRdID = int.Parse(this.txtRdID.Text.Trim()); rdout.cnvcPOID = this.txtCode.Text.Trim(); rdout.cnvcInvCode = item.Cells[0].Text.Trim(); rdout.cnnQuantity = Math.Round((dmovecountCom - dalreadycount) / decimal.Parse(dtrate.Rows[0]["cniChangRate"].ToString()), 2); rdout.cnnPrice = Math.Round(decimal.Parse(item.Cells[2].Text.Trim()), 2); rdout.cnnCost = rdout.cnnQuantity * rdout.cnnPrice; rdout.cnvcGroupCode = item.Cells[3].Text.Trim(); rdout.cnvcComunitCode = item.Cells[4].Text.Trim(); rdout.cnvcFlag = "0"; rdout.cndMdate = (DateTime)dtinv.Rows[i]["cndMdate"]; rdout.cndExpDate = (DateTime)dtinv.Rows[i]["cndExpDate"]; alrdout.Add(rdout); RdRecordDetail rdin = new RdRecordDetail(); rdin.cnnRdID = int.Parse(strRdid); rdin.cnvcPOID = this.txtCode.Text.Trim(); rdin.cnvcInvCode = item.Cells[0].Text.Trim(); rdin.cnnQuantity = Math.Round((dmovecountCom - dalreadycount) / decimal.Parse(dtrate.Rows[0]["cniChangRate"].ToString()), 2); rdin.cnnPrice = Math.Round(decimal.Parse(item.Cells[2].Text.Trim()), 2); rdin.cnnCost = rdin.cnnQuantity * rdin.cnnPrice; rdin.cnvcGroupCode = item.Cells[3].Text.Trim(); rdin.cnvcComunitCode = item.Cells[4].Text.Trim(); rdin.cnvcFlag = "0"; rdin.cndMdate = rdout.cndMdate; rdin.cndExpDate = rdout.cndExpDate; alrdin.Add(rdin); dalreadycount += dmovecountCom - dalreadycount; break; } else { RdRecordDetail rdout = new RdRecordDetail(); rdout.cnnRdID = int.Parse(this.txtRdID.Text.Trim()); rdout.cnvcPOID = this.txtCode.Text.Trim(); rdout.cnvcInvCode = item.Cells[0].Text.Trim(); rdout.cnnQuantity = Math.Round(decimal.Parse(dtinv.Rows[i]["cnnAvaQuantity"].ToString()) / decimal.Parse(dtrate.Rows[0]["cniChangRate"].ToString()), 2); rdout.cnnPrice = Math.Round(decimal.Parse(item.Cells[2].Text.Trim()), 2); rdout.cnnCost = rdout.cnnQuantity * rdout.cnnPrice; rdout.cnvcGroupCode = item.Cells[3].Text.Trim(); rdout.cnvcComunitCode = item.Cells[4].Text.Trim(); rdout.cnvcFlag = "0"; rdout.cndMdate = (DateTime)dtinv.Rows[i]["cndMdate"]; rdout.cndExpDate = (DateTime)dtinv.Rows[i]["cndExpDate"]; alrdout.Add(rdout); RdRecordDetail rdin = new RdRecordDetail(); rdin.cnnRdID = int.Parse(strRdid); rdin.cnvcPOID = this.txtCode.Text.Trim(); rdin.cnvcInvCode = item.Cells[0].Text.Trim(); rdin.cnnQuantity = Math.Round(decimal.Parse(dtinv.Rows[i]["cnnAvaQuantity"].ToString()) / decimal.Parse(dtrate.Rows[0]["cniChangRate"].ToString()), 2); rdin.cnnPrice = Math.Round(decimal.Parse(item.Cells[2].Text.Trim()), 2); rdin.cnnCost = rdin.cnnQuantity * rdin.cnnPrice; rdin.cnvcGroupCode = item.Cells[3].Text.Trim(); rdin.cnvcComunitCode = item.Cells[4].Text.Trim(); rdin.cnvcFlag = "0"; rdin.cndMdate = rdout.cndMdate; rdin.cndExpDate = rdout.cndExpDate; alrdin.Add(rdin); dalreadycount += Math.Round(decimal.Parse(dtinv.Rows[i]["cnnAvaQuantity"].ToString()), 2); } } if (dalreadycount != dmovecountCom) { this.Popup("系统错误,调拨数量不正确,请重试!"); return; } OperLog operLog = new OperLog(); operLog.cnvcOperType = "添加调拨存货"; operLog.cnvcOperID = this.oper.strLoginID; operLog.cnvcDeptID = this.oper.strDeptID; StorageFacade sto = new StorageFacade(); int ret = sto.AddRdRecordMoveDetail(operLog, alrdout, alrdin); if (ret > 0) { this.Popup("添加调拨存货成功!"); } else { this.Popup("添加调拨存货失败!"); } this.DataGrid1.DataSource = null; this.DataGrid1.DataBind(); this.DBBind(); }
private void Datagrid2_UpdateCommand(object source, DataGridCommandEventArgs e) { if (((TextBox)e.Item.Cells[6].Controls[0]).Text.Trim() == "" || !this.JudgeIsNum(((TextBox)e.Item.Cells[6].Controls[0]).Text.Trim())) { this.Popup("单价必须是数字!"); this.hidecontrol(e.Item.ItemIndex); return; } if (((TextBox)e.Item.Cells[11].Controls[1]).Text.Trim() == "" || !this.JudgeIsNum(((TextBox)e.Item.Cells[11].Controls[1]).Text.Trim())) { this.Popup("入库数量必须是数字!"); this.hidecontrol(e.Item.ItemIndex); return; } if (((TextBox)e.Item.Cells[14].Controls[1]).Text.Trim() == "" || !this.JudgeIsNum(((TextBox)e.Item.Cells[14].Controls[1]).Text.Trim())) { this.Popup("其它费用数量必须是数字!"); this.hidecontrol(e.Item.ItemIndex); return; } if (((System.Web.UI.HtmlControls.HtmlInputText)e.Item.Cells[16].Controls[1]).Value == "") { this.Popup("生产日期不能为空!"); this.hidecontrol(e.Item.ItemIndex); return; } if (((System.Web.UI.HtmlControls.HtmlInputText)e.Item.Cells[18].Controls[1]).Value == "") { this.Popup("过期日期不能为空!"); this.hidecontrol(e.Item.ItemIndex); return; } string strExpire = Helper.Query("select cnnExpire from tbInventory where cnvcInvCode='" + e.Item.Cells[4].Text.Trim() + "'").Rows[0]["cnnExpire"].ToString(); if (strExpire != "" && strExpire != "0") { DateTime dtExpdate = DateTime.Parse(((System.Web.UI.HtmlControls.HtmlInputText)e.Item.Cells[18].Controls[1]).Value); TimeSpan ts = dtExpdate.Subtract(DateTime.Now.Date); if (ts.Days <= int.Parse(strExpire)) { this.Popup("到期天数不足" + strExpire + "天,不能入库!"); this.hidecontrol(e.Item.ItemIndex); return; } } Entity.RdRecordDetail rrd = new RdRecordDetail(); rrd.cnnAutoID = int.Parse(e.Item.Cells[0].Text.Trim()); rrd.cnnPrice = Math.Round(decimal.Parse(((TextBox)e.Item.Cells[6].Controls[0]).Text.Trim()), 2); rrd.cnnQuantity = Math.Round(decimal.Parse(((TextBox)e.Item.Cells[11].Controls[1]).Text.Trim()), 2); rrd.cnnExtraCost = Math.Round(decimal.Parse(((TextBox)e.Item.Cells[14].Controls[1]).Text.Trim()), 2); rrd.cndMdate = DateTime.Parse(((System.Web.UI.HtmlControls.HtmlInputText)e.Item.Cells[16].Controls[1]).Value.Trim()); rrd.cndExpDate = DateTime.Parse(((System.Web.UI.HtmlControls.HtmlInputText)e.Item.Cells[18].Controls[1]).Value.Trim()); rrd.cnvcCommens = ((TextBox)e.Item.Cells[19].Controls[0]).Text.Trim(); if (rrd.cnnAutoID.ToString() == "" || rrd.cnnAutoID == 0) { this.Popup("采购入库单子表标识不正确!"); this.hidecontrol(e.Item.ItemIndex); return; } if (rrd.cndMdate.CompareTo(rrd.cndExpDate) >= 0) { this.Popup("生产日期大于过期日期,不正确!"); this.hidecontrol(e.Item.ItemIndex); return; } // DateTime dttmp=rrd.cndMdate; // switch(rrd.cnvcMassUnit) // { // case "1": // if(dttmp.AddDays(rrd.cnnMassDate).CompareTo(rrd.cndExpDate)!=0) // { // this.Popup("生产日期+保质期数后不等于过期日期,请检查!"); // this.hidecontrol(e.Item.ItemIndex); // return; // } // break; // case "2": // if(dttmp.AddMonths(rrd.cnnMassDate).CompareTo(rrd.cndExpDate)!=0) // { // this.Popup("生产日期+保质期数后不等于过期日期,请检查!"); // this.hidecontrol(e.Item.ItemIndex); // return; // } // break; // case "3": // if(dttmp.AddYears(rrd.cnnMassDate).CompareTo(rrd.cndExpDate)!=0) // { // this.Popup("生产日期+保质期数后不等于过期日期,请检查!"); // this.hidecontrol(e.Item.ItemIndex); // return; // } // break; // } Entity.OperLog ol = new AMSApp.zhenghua.Entity.OperLog(); ol.cnvcOperType = "修改采购入库子表"; ol.cnvcOperID = this.oper.strLoginID; ol.cnvcDeptID = this.oper.strDeptID; StorageFacade sto = new StorageFacade(); int ret = sto.UpdatePoStockEnterDetail(ol, rrd); if (ret > 0) { this.Popup("修改采购入库单子表明细成功!"); } else { this.Popup("修改采购入库单子表明细失败!"); } this.DBBind(); }
private void Button2_Click(object sender, System.EventArgs e) { //领料单打印 ArrayList al = new ArrayList(); DataTable dtInv = Application["tbInventory"] as DataTable; foreach (DataGridItem dgi in this.DataGrid1.Items) { string strinvcode = dgi.Cells[0].Text; string strinvname = dgi.Cells[1].Text; string stroutcount = dgi.Cells[6].Text; string strwhcount = dgi.Cells[7].Text; bool iscollar = ((CheckBox)dgi.Cells[8].Controls[1]).Checked; if (iscollar) { //this.Popup(strinvname+"已经完成了生产材料领用"); this.Popup("已经领用生产材料"); return; } if (!this.JudgeIsNum(strwhcount)) { this.Popup(strinvname + "无库存,不能领用原材料,请检查原材料库存"); return; } decimal doutcount = Convert.ToDecimal(stroutcount); decimal dwhcount = Convert.ToDecimal(strwhcount); if (doutcount > dwhcount) { this.Popup(strinvname + "库存数量不足,不能领用原材料进行生产,请检查原材料库存"); return; } Entity.RdRecordDetail rrd = new RdRecordDetail(); rrd.cnvcInvCode = strinvcode; rrd.cnnQuantity = Convert.ToDecimal(stroutcount); DataRow[] drInvs = dtInv.Select("cnvcInvCode='" + strinvcode + "'"); if (drInvs.Length == 0) { this.Popup(strinvname + "存货档案未找到"); return; } Entity.Inventory inv = new AMSApp.zhenghua.Entity.Inventory(drInvs[0]); rrd.cnvcGroupCode = inv.cnvcGroupCode; rrd.cnvcComunitCode = inv.cnvcSTComUnitCode; rrd.cnvcFlag = "0"; al.Add(rrd); } Entity.RdRecord rr = new RdRecord(); rr.cnvcRdCode = "RD008"; rr.cnvcRdFlag = "0"; rr.cnvcWhCode = this.ddlWarehouse.SelectedValue; rr.cnvcDepID = this.ddlProduceDept.SelectedValue; rr.cnvcOperName = this.oper.strOperName; rr.cnvcComments = "生产材料领用"; rr.cnvcMaker = this.oper.strLoginID; rr.cnnProorderID = Convert.ToDecimal(this.txtProduceSerialNo.Text); rr.cnvcState = "2"; OperLog ol = new OperLog(); ol.cnvcOperID = this.oper.strLoginID; ol.cnvcDeptID = this.oper.strDeptID; ol.cnvcOperType = "生产材料领用"; string strWarehouse = this.ddlWarehouse.SelectedValue; try { ProduceFacade pf = new ProduceFacade(); pf.Collar(this.txtMakeSerialNo.Text, rr, al, ol, strWarehouse); this.Popup("生产材料领用成功"); } catch (Exception ex) { this.Popup(ex.Message); } BindGrid(); }