Exemple #1
0
        public void AddProductSerial(ArrayList alProductSerial, 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 < alProductSerial.Count; i++)
                    {
                        ProductSerial productSerial = (ProductSerial)alProductSerial[i];
                        productSerial.cndOperDate = dtSysTime;
                        productSerial.cnnSerialNo = serialNo.cnnSerialNo;
                        EntityMapping.Create(productSerial, trans);

                        ProductSerialLog productSerialLog = new ProductSerialLog(productSerial.ToTable());
                        //productSerialLog.cnnSerialNo = null;
                        productSerialLog.cnnProductSerialNo = serialNo.cnnSerialNo;
                        EntityMapping.Create(productSerialLog, 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);
                }
            }
        }
Exemple #2
0
        public void AdjustProductSerial_Add(ProductSerial productSerial, 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);

                    ProductSerial oldProductSerial = EntityMapping.Get(productSerial, trans) as ProductSerial;
                    if (oldProductSerial == null)
                    {
                        throw new Exception("未找到对应生产流水的产品!");
                    }

                    oldProductSerial.cnnAddCount = productSerial.cnnAddCount;
                    oldProductSerial.cnvcOperID  = operLog.cnvcOperID;
                    oldProductSerial.cndOperDate = dtSysTime;
                    EntityMapping.Update(oldProductSerial, trans);

                    ProductSerialLog productSerialLog = new ProductSerialLog(oldProductSerial.ToTable());
                    productSerialLog.cnnProductSerialNo = oldProductSerial.cnnSerialNo;
                    EntityMapping.Create(productSerialLog, trans);

                    operLog.cndOperDate  = dtSysTime;
                    operLog.cnvcComments = "生产产品调增,生产流水:" + oldProductSerial.cnnSerialNo.ToString() + ",产品编码:" + productSerial.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);
                }
            }
        }