コード例 #1
0
        public void AddSalesSerial(ArrayList alSalesSerial, 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 < alSalesSerial.Count; i++)
                    {
                        SalesSerial salesSerial = (SalesSerial)alSalesSerial[i];
                        salesSerial.cndOperDate = dtSysTime;
                        salesSerial.cnnSerialNo = serialNo.cnnSerialNo;
                        EntityMapping.Create(salesSerial, trans);

                        SalesSerialLog salesSerialLog = new SalesSerialLog(salesSerial.ToTable());
                        //salesSerialLog.cnnSerialNo = null;
                        salesSerialLog.cnnSalesSerialNo = serialNo.cnnSerialNo;
                        EntityMapping.Create(salesSerialLog, 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);
                }
            }
        }
コード例 #2
0
        public void AdjustSalesSerial_Delete(SalesSerial salesSerial, 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);

                    SalesSerial oldSalesSerial = EntityMapping.Get(salesSerial, trans) as SalesSerial;
                    if (oldSalesSerial == null)
                    {
                        throw new Exception("未找到对应销售流水的产品!");
                    }

                    oldSalesSerial.cnnReduceCount = salesSerial.cnnReduceCount;
                    oldSalesSerial.cnvcOperID     = operLog.cnvcOperID;
                    oldSalesSerial.cndOperDate    = dtSysTime;
                    EntityMapping.Delete(oldSalesSerial, trans);

                    SalesSerialLog salesSerialLog = new SalesSerialLog(oldSalesSerial.ToTable());
                    salesSerialLog.cnnSalesSerialNo = oldSalesSerial.cnnSerialNo;
                    EntityMapping.Create(salesSerialLog, trans);

                    operLog.cndOperDate  = dtSysTime;
                    operLog.cnvcComments = "销售删除,生产流水:" + oldSalesSerial.cnnSerialNo.ToString() + ",产品编码:" + salesSerial.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);
                }
            }
        }