private void Button2_Click(object sender, System.EventArgs e) { //生产产品入库 DataTable dtLostSerial = GetProduct(); ArrayList alLostSerial = new ArrayList(); if (dtLostSerial.Rows.Count > 0) { foreach (DataRow dr in dtLostSerial.Rows) { LostSerial ps = new LostSerial(dr); ps.cndLostDate = Convert.ToDateTime(TextBox1.Text); ps.cnvcOperID = oper.strLoginID; ps.cnvcDeptID = ddlDept.SelectedValue; alLostSerial.Add(ps); } OperLog ol = new OperLog(); ol.cnvcDeptID = oper.strDeptID; ol.cnvcOperID = oper.strLoginID; ol.cnvcOperType = "生产产品报损"; ProductFacade pf = new ProductFacade(); pf.AddProductLostSerial(alLostSerial, ol); this.Popup("生产产品报损成功!"); //清理数据 Session.Remove("tbLostSerial"); BindGrid(); } }
private DataTable GetNULLGrid() { Entity.LostSerial ls = new LostSerial(); DataTable dt = ls.ToTable(); dt.Columns.Add("cnvcInvName"); return(dt.Clone()); }
public void AddProductLostSerial(ArrayList alLostSerial, OperLog operLog) //,BusiLog busiLog) { 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); SerialNo serialNo = new SerialNo(); serialNo.cnvcFill = "0"; serialNo.cnnSerialNo = Convert.ToInt32(EntityMapping.Create(serialNo, trans)); for (int i = 0; i < alLostSerial.Count; i++) { LostSerial ls = (LostSerial)alLostSerial[i]; ls.cnvcLostType = "0"; ls.cndOperDate = dtSysTime; ls.cnnLostSerialNo = serialNo.cnnSerialNo; EntityMapping.Create(ls, trans); // ProductLostSerialLog productLostSerialLog = new ProductLostSerialLog(productLostSerial.ToTable()); // //productSerialLog.cnnSerialNo = null; // productLostSerialLog.cnnProductLostSerialNo = serialNo.cnnSerialNo; // EntityMapping.Create(productLostSerialLog, trans); } operLog.cndOperDate = dtSysTime; operLog.cnvcComments = "生产产品报损,报损流水:" + serialNo.cnnSerialNo.ToString(); 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 btMod_Click(object sender, System.EventArgs e) { strLostDate = Request.Form["txtLostDate"].ToString(); if (strLostDate == "" || strLostDate == null) { this.Popup("损耗时间不能为空,请重新选择时间!"); return; } if (this.txtAddCount.Text.Trim() == "" || this.txtReduceCount.Text.Trim() == "") { this.Popup("调增量和调减量不能为空!"); return; } Entity.LostSerial ls = new LostSerial(); ls.cnnLostSerialNo = int.Parse(this.txtSerialNo.Text.Trim()); ls.cnnAddCount = Math.Round(decimal.Parse(this.txtAddCount.Text.Trim()), 2); ls.cnnReduceCount = Math.Round(decimal.Parse(this.txtReduceCount.Text.Trim()), 2); ls.cndLostDate = DateTime.Parse(strLostDate); ls.cnvcComments = this.txtComments.Text.Trim(); ls.cnvcOperID = this.oper.strLoginID; if (ls.cnnLostSerialNo.ToString() == "") { this.Popup("损耗流水不正确!"); return; } string strsql = "select count(*) from tbLostSerial a,tbCurrentStock b,tbComputationUnit c where a.cnnLostSerialNo=" + ls.cnnLostSerialNo.ToString() + " and a.cnvcInvCode=b.cnvcInvCode and a.cnvcWhCode=b.cnvcWhCode"; strsql += " and convert(char(8),a.cndMdate,112)=convert(char(8),b.cndMdate,112) and convert(char(8),a.cndExpDate,112)=convert(char(8),b.cndExpDate,112)"; strsql += " and a.cnvcComunitCode=c.cnvcComunitCode and a.cnnLostCount+a.cnnAddCount-a.cnnReduceCount>(b.cnnQuantity*c.cniChangRate)"; DataTable dterrcount = Helper.Query(strsql); if (dterrcount.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.UpdateLostSerial(ol, ls); if (ret > 0) { this.Popup("修改过期损耗成功!"); } else { this.Popup("修改过期损耗失败!"); } }
public void AdjustProductLostSerial_Add(LostSerial ls, OperLog operLog) //,BusiLog busiLog) { 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); LostSerial oldls = EntityMapping.Get(ls, trans) as LostSerial; if (oldls == null) { throw new Exception("未找到对应报损流水的产品!"); } oldls.cnnAddCount = ls.cnnAddCount; oldls.cnnReduceCount = ls.cnnReduceCount; oldls.cnvcOperID = operLog.cnvcOperID; oldls.cndOperDate = dtSysTime; EntityMapping.Update(oldls, trans); // ProductLostSerialLog productLostSerialLog = new ProductLostSerialLog(oldProductLostSerial.ToTable()); // productLostSerialLog.cnnProductLostSerialNo = oldProductLostSerial.cnnSerialNo; // EntityMapping.Create(productLostSerialLog, trans); operLog.cndOperDate = dtSysTime; operLog.cnvcComments = "生产产品报损调整,报损流水:" + oldls.cnnLostSerialNo.ToString() + ",产品编码:" + ls.cnvcInvCode; 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 btAdd_Click(object sender, System.EventArgs e) { strLostDate = Request.Form["txtLostDate"].ToString(); if (strLostDate == "" || strLostDate == null) { this.Popup("损耗时间不能为空,请重新选择时间!"); return; } if (this.txtLostCount.Text.Trim() == "") { this.Popup("损耗数量不能为空!"); return; } if (this.txtMdate.Text.Trim() == "" || this.txtExpDate.Text.Trim() == "") { this.Popup("生产日期和过期日期不能为空!"); return; } Entity.LostSerial ls = new LostSerial(); ls.cnvcInvCode = this.txtInvCode.Text.Trim(); ls.cnnLostCount = Math.Round(decimal.Parse(this.txtLostCount.Text.Trim()), 2); ls.cnnAddCount = 0; ls.cnnReduceCount = 0; ls.cndLostDate = DateTime.Parse(strLostDate); ls.cnvcDeptID = this.ddlDeptID.SelectedValue; ls.cnvcWhCode = this.ddlWhouse.SelectedValue; ls.cnvcOperID = this.oper.strLoginID; ls.cnvcLostType = "1"; ls.cnvcComments = this.txtComments.Text.Trim(); ls.cnvcInvalidFlag = "0"; ls.cnvcComunitCode = this.txtUnitCode.Text.Trim(); ls.cndMdate = DateTime.Parse(this.txtMdate.Text.Trim()); ls.cndExpDate = DateTime.Parse(this.txtExpDate.Text.Trim()); if (ls.cnvcDeptID == "" || ls.cnvcWhCode == "") { this.Popup("部门和仓库不能为空!"); return; } if (ls.cnvcInvCode == "") { this.Popup("报损存货不能为空!"); return; } if (ls.cndExpDate.CompareTo(DateTime.Now) > 0) { this.Popup("此存货尚未过期,不能报废!"); return; } string strsql = "select cast(cnnQuantity/(select cniChangRate from tbComputationUnit where cnvcComunitCode='" + ls.cnvcComunitCode + "') as numeric(10,4)) as cnnQuantity from tbCurrentStock"; strsql += " where cnvcWhCode='" + ls.cnvcWhCode + "' and cnvcInvCode='" + ls.cnvcInvCode + "' and convert(char(10),cndMdate,121)='" + ls.cndMdate.ToString("yyyy-MM-dd") + "' and convert(char(10),cndExpDate,121)='" + ls.cndExpDate.ToString("yyyy-MM-dd") + "'"; string strQuantity = Helper.Query(strsql).Rows[0]["cnnQuantity"].ToString(); if (ls.cnnLostCount > Math.Round(decimal.Parse(strQuantity), 2)) { 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.AddLostSerial(ol, ls); if (ret > 0) { this.Popup("添加过期损耗成功!"); } else { this.Popup("添加过期损耗失败!"); } }
private void MyDataGrid_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { string strSerialNo; // = e.Item.Cells[0].Text; string strGoodsID; // = e.Item.Cells[1].Text; string strCount; // = e.Item.Cells[4].Text; LostSerial ps; OperLog ol; ProductFacade pf; DataRow[] drs; DataTable dtProduct = GetProduct(); if (e.CommandName == "Delete") { strSerialNo = e.Item.Cells[0].Text; strGoodsID = e.Item.Cells[1].Text; //strCount = e.Item.Cells[4].Text; drs = dtProduct.Select("cnvcInvCode='" + strGoodsID + "' and cnnLostSerialNo=" + strSerialNo); if (drs.Length > 0) { dtProduct.Rows.Remove(drs[0]); //drs[0]["cnnCount"] = strCount; } ps = new LostSerial(); ps.cnnLostSerialNo = Convert.ToInt32(strSerialNo); ps.cnvcInvCode = strGoodsID; ol = new OperLog(); ol.cnvcDeptID = oper.strDeptID; ol.cnvcOperID = oper.strLoginID; ol.cnvcOperType = "生产产品报损删除"; pf = new ProductFacade(); pf.AdjustProductLostSerial_Delete(ps, ol); SetProduct(dtProduct); this.Popup("产品报损删除成功!"); if ((this.MyDataGrid.CurrentPageIndex == MyDataGrid.PageCount - 1) && MyDataGrid.Items.Count == 1) { if (MyDataGrid.CurrentPageIndex - 1 > 1) { MyDataGrid.CurrentPageIndex = MyDataGrid.CurrentPageIndex - 1; } else { MyDataGrid.CurrentPageIndex = 0; } } BindGrid(); } else if (e.CommandName == "Adjust") { strSerialNo = e.Item.Cells[0].Text; strGoodsID = e.Item.Cells[1].Text; strCount = e.Item.Cells[4].Text; string strAddCount = ((TextBox)e.Item.Cells[5].Controls[1]).Text; string strReduceCount = ((TextBox)e.Item.Cells[6].Controls[1]).Text; if (strAddCount == "") { this.Popup("请输入调增量!"); return; } if (!this.JudgeIsNum(strAddCount)) { this.Popup("调增量请输入数字!"); return; } if (Convert.ToDecimal(strAddCount) <= 0) { this.Popup("调增量必须大于等于零!"); return; } if (strReduceCount == "") { this.Popup("请输入调减量!"); return; } if (!this.JudgeIsNum(strReduceCount)) { this.Popup("调减量请输入数字!"); return; } if (Convert.ToInt32(strReduceCount) <= 0) { this.Popup("调减量必须大于零!"); return; } if (Convert.ToDecimal(strCount) + Convert.ToDecimal(strAddCount) - Convert.ToDecimal(strReduceCount) <= 0) { this.Popup("调减量必须小于报损量加调增量!"); return; } // switch(e.CommandName) // { // case "AdjustAdd": drs = dtProduct.Select("cnvcInvCode='" + strGoodsID + "' and cnnLostSerialNo=" + strSerialNo); if (drs.Length > 0) { drs[0]["cnnAddCount"] = strAddCount; drs[0]["cnnReduceCount"] = strReduceCount; drs[0]["cnnSum"] = Convert.ToDecimal(strCount) + Convert.ToDecimal(strAddCount) - Convert.ToDecimal(strReduceCount); } ps = new LostSerial(); ps.cnnLostSerialNo = Convert.ToInt32(strSerialNo); ps.cnvcInvCode = strGoodsID; ps.cnnAddCount = Convert.ToDecimal(strAddCount); ol = new OperLog(); ol.cnvcDeptID = oper.strDeptID; ol.cnvcOperID = oper.strLoginID; ol.cnvcOperType = "生产产品报损调增"; pf = new ProductFacade(); pf.AdjustProductLostSerial_Add(ps, ol); SetProduct(dtProduct); this.Popup("调整成功!"); BindGrid(); // break; // case "AdjustReduce": // drs = dtProduct.Select("cnvcInvCode='"+strGoodsID+"' and cnnLostSerialNo="+strSerialNo); // if(drs.Length>0) // { // drs[0]["cnnReduceCount"] = strReduceCount; // drs[0]["cnnSum"] = Convert.ToDecimal(strCount)-Convert.ToDecimal(strReduceCount); // } // // ps = new LostSerial(); // ps.cnnLostSerialNo = Convert.ToInt32(strSerialNo); // ps.cnvcInvCode = strGoodsID; // ps.cnnReduceCount = Convert.ToDecimal(strReduceCount); // // // ol = new OperLog(); // ol.cnvcDeptID = oper.strDeptID; // ol.cnvcOperID = oper.strLoginID; // ol.cnvcOperType = "生产产品报损调减"; // // pf = new ProductFacade(); // pf.AdjustProductLostSerial_Reduce(ps,ol); // // SetProduct(dtProduct); // this.Popup("调减成功!"); // BindGrid(); // break; } }