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); } } }