private void Button2_Click(object sender, System.EventArgs e) { //生产产品入库 DataTable dtCheckSerial = GetProduct(); ArrayList alCheckSerial = new ArrayList(); if (dtCheckSerial.Rows.Count > 0) { foreach (DataRow dr in dtCheckSerial.Rows) { CheckSerial ps = new CheckSerial(dr); ps.cndCreateDate = Convert.ToDateTime(TextBox1.Text); ps.cnvcOperID = oper.strLoginID; ps.cnvcDeptID = ddlDept.SelectedValue; alCheckSerial.Add(ps); } OperLog ol = new OperLog(); ol.cnvcDeptID = oper.strDeptID; ol.cnvcOperID = oper.strLoginID; ol.cnvcOperType = "盘点产品入库"; ProductFacade pf = new ProductFacade(); pf.AddCheckSerial(alCheckSerial, ol); this.Popup("盘点产品入库成功!"); //清理数据 Session.Remove("tbCheckSerial"); BindGrid(); } }
public void AddCheckSerial(ArrayList alCheckSerial, 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 < alCheckSerial.Count; i++) { CheckSerial checkSerial = (CheckSerial)alCheckSerial[i]; checkSerial.cndOperDate = dtSysTime; checkSerial.cnnSerialNo = serialNo.cnnSerialNo; EntityMapping.Create(checkSerial, trans); CheckSerialLog checkSerialLog = new CheckSerialLog(checkSerial.ToTable()); //CheckSerialLog.cnnSerialNo = null; checkSerialLog.cnnCheckSerialNo = serialNo.cnnSerialNo; EntityMapping.Create(checkSerialLog, 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); } } }
public void AdjustCheckSerial_Delete(CheckSerial CheckSerial, 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); CheckSerial oldCheckSerial = EntityMapping.Get(CheckSerial, trans) as CheckSerial; if (oldCheckSerial == null) { throw new Exception("未找到对应盘点流水的产品!"); } oldCheckSerial.cnnReduceCount = CheckSerial.cnnReduceCount; oldCheckSerial.cnvcOperID = operLog.cnvcOperID; oldCheckSerial.cndOperDate = dtSysTime; EntityMapping.Delete(oldCheckSerial, trans); CheckSerialLog checkSerialLog = new CheckSerialLog(oldCheckSerial.ToTable()); checkSerialLog.cnnCheckSerialNo = oldCheckSerial.cnnSerialNo; EntityMapping.Create(checkSerialLog, trans); operLog.cndOperDate = dtSysTime; operLog.cnvcComments = "盘点删除,盘点流水:" + oldCheckSerial.cnnSerialNo.ToString() + ",产品编码:" + CheckSerial.cnvcCode; 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 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; CheckSerial ps; OperLog ol; ProductFacade pf; DataRow[] drs; DataTable dtProduct = GetProduct(); switch (e.CommandName) { case "AdjustAdd": 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; if (strAddCount == "") { this.Popup("请输入调增量!"); return; } if (!this.JudgeIsNum(strAddCount)) { this.Popup("请输入数字!"); return; } if (Convert.ToInt32(strAddCount) <= 0) { this.Popup("调增量必须大于零!"); return; } drs = dtProduct.Select("cnvcCode='" + strGoodsID + "' and cnnSerialNo=" + strSerialNo); if (drs.Length > 0) { drs[0]["cnnAddCount"] = strAddCount; drs[0]["cnnSum"] = Convert.ToInt32(strCount) + Convert.ToInt32(strAddCount); } ps = new CheckSerial(); ps.cnnSerialNo = Convert.ToInt32(strSerialNo); ps.cnvcCode = strGoodsID; ps.cnnAddCount = Convert.ToInt32(strAddCount); ol = new OperLog(); ol.cnvcDeptID = oper.strDeptID; ol.cnvcOperID = oper.strLoginID; ol.cnvcOperType = "盘点产品调增"; pf = new ProductFacade(); pf.AdjustCheckSerial_Add(ps, ol); SetProduct(dtProduct); this.Popup("调增成功!"); BindGrid(); break; case "AdjustReduce": strSerialNo = e.Item.Cells[0].Text; strGoodsID = e.Item.Cells[1].Text; strCount = e.Item.Cells[4].Text; string strReduceCount = ((TextBox)e.Item.Cells[6].Controls[1]).Text; if (strReduceCount == "") { this.Popup("请输入调减量!"); return; } if (!this.JudgeIsNum(strReduceCount)) { this.Popup("请输入数字!"); return; } if (Convert.ToInt32(strReduceCount) <= 0) { this.Popup("调减量必须大于零!"); return; } if (Convert.ToInt32(strCount) - Convert.ToInt32(strReduceCount) <= 0) { this.Popup("调减量必须小于盘点量!"); return; } drs = dtProduct.Select("cnvcCode='" + strGoodsID + "' and cnnSerialNo=" + strSerialNo); if (drs.Length > 0) { drs[0]["cnnReduceCount"] = strReduceCount; drs[0]["cnnSum"] = Convert.ToInt32(strCount) - Convert.ToInt32(strReduceCount); } ps = new CheckSerial(); ps.cnnSerialNo = Convert.ToInt32(strSerialNo); ps.cnvcCode = strGoodsID; ps.cnnReduceCount = Convert.ToInt32(strReduceCount); ol = new OperLog(); ol.cnvcDeptID = oper.strDeptID; ol.cnvcOperID = oper.strLoginID; ol.cnvcOperType = "盘点产品调减"; pf = new ProductFacade(); pf.AdjustCheckSerial_Reduce(ps, ol); SetProduct(dtProduct); this.Popup("调减成功!"); BindGrid(); break; case "Delete": strSerialNo = e.Item.Cells[0].Text; strGoodsID = e.Item.Cells[1].Text; //strCount = e.Item.Cells[4].Text; drs = dtProduct.Select("cnvcCode='" + strGoodsID + "' and cnnSerialNo=" + strSerialNo); if (drs.Length > 0) { dtProduct.Rows.Remove(drs[0]); //drs[0]["cnnCount"] = strCount; } ps = new CheckSerial(); ps.cnnSerialNo = Convert.ToInt32(strSerialNo); ps.cnvcCode = strGoodsID; ol = new OperLog(); ol.cnvcDeptID = oper.strDeptID; ol.cnvcOperID = oper.strLoginID; ol.cnvcOperType = "盘点产品删除"; pf = new ProductFacade(); pf.AdjustCheckSerial_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(); break; } }