Ejemplo n.º 1
0
        public static DataTable Query(string strSql)
        {
            SqlConnection conn  = ConnectionPool.BorrowConnection();
            DataTable     dtRet = null;

            try
            {
                //conn.ConnectionTimeout = 300;
                //SqlHelper.
                dtRet = SqlHelper.ExecuteDataTable(conn, CommandType.Text, strSql);
            }
            catch (SqlException sex)
            {
                LogAdapter.WriteDatabaseException(sex);
                throw sex;
            }
            catch (Exception ex)
            {
                LogAdapter.WriteFeaturesException(ex);
                throw ex;
            }
            finally
            {
                ConnectionPool.ReturnConnection(conn);
            }
            return(dtRet);
        }
Ejemplo n.º 2
0
        public void UpdateOrder(OrderBook order, 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);

                    OrderBook oldOrder = new OrderBook();
                    oldOrder.cnnOrderSerialNo = order.cnnOrderSerialNo;
                    oldOrder = EntityMapping.Get(oldOrder, trans) as OrderBook;
                    if (oldOrder == null)
                    {
                        throw new Exception("订单未找到");
                    }
                    oldOrder.cnvcOrderOperID   = order.cnvcOrderOperID;
                    oldOrder.cnvcOrderType     = order.cnvcOrderType;
                    oldOrder.cnvcProduceDeptID = order.cnvcProduceDeptID;
                    oldOrder.cnvcOrderDeptID   = order.cnvcOrderDeptID;

                    if (oldOrder.cnvcOrderType == "WDO")
                    {
                        oldOrder.cndArrivedDate  = order.cndArrivedDate;
                        oldOrder.cnvcLinkPhone   = order.cnvcLinkPhone;
                        oldOrder.cnvcShipAddress = order.cnvcShipAddress;
                        oldOrder.cnvcCustomName  = order.cnvcCustomName;
                    }
                    //order.cnnOrderSerialNo = decimal.Parse(txtOrderSerialNo.Text);
                    oldOrder.cndShipDate = order.cndShipDate;
                    EntityMapping.Update(oldOrder, trans);

                    operLog.cndOperDate  = dtSysTime;
                    operLog.cnvcComments = "订单流水:" + oldOrder.cnnOrderSerialNo;
                    EntityMapping.Create(operLog, trans);

                    //EntityMapping.Create(busiLog, 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);
                }
            }
        }
Ejemplo n.º 3
0
        public void UpdateAssignLog(AssignDetail detail, OperLog operLog)
        {
            using (SqlConnection conn = ConnectionPool.BorrowConnection())
            {
                //conn.Open();

                SqlTransaction trans = conn.BeginTransaction();
                try
                {
//
//					AssignDetail detail = new AssignDetail();
//					detail.cnnAssignSerialNo = detailLog.cnnAssignSerialNo;
//					detail.cnnOrderSerialNo = detailLog.cnnOrderSerialNo;
//					detail.cnvcProductCode = detailLog.cnvcProductCode;
                    AssignDetail detailOld = EntityMapping.Get(detail, trans) as AssignDetail;
                    if (detail.cnnCount != detailOld.cnnCount)
                    {
                        string   strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString();
                        DateTime dtSysTime  = DateTime.Parse(strSysTime);

                        OrderSerialNo serialNo = new OrderSerialNo();
                        serialNo.cnvcFill    = "0";
                        serialNo.cnnSerialNo = Convert.ToDecimal(EntityMapping.Create(serialNo, trans));

                        detailOld.cnnCount = detail.cnnCount;
                        detailOld.cnnSum   = Math.Round(detail.cnnCount * detailOld.cnnPrice, 2);
                        EntityMapping.Update(detailOld, trans);

                        AssignDetailLog detailLog = new AssignDetailLog(detailOld.ToTable());
                        detailLog.cnvcOperID  = operLog.cnvcOperID;
                        detailLog.cndOperDate = dtSysTime;
                        detailLog.cnnSerialNo = serialNo.cnnSerialNo;
                        EntityMapping.Create(detailLog, trans);

                        operLog.cndOperDate  = dtSysTime;
                        operLog.cnvcComments = "生产流水:" + detail.cnnAssignSerialNo.ToString() + ",日志流水:" + 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);
                }
            }
        }
Ejemplo n.º 4
0
        public void UpdateBook(Book book, OperLog operLog)
        {
            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);

                    Entity.Book oldbook = new Book();
                    oldbook.cnnSerialNo = book.cnnSerialNo;
                    oldbook             = EntityMapping.Get(oldbook, trans) as Book;
                    if (oldbook == null)
                    {
                        throw new Exception("未找到留言内容!");
                    }
                    if (oldbook.cnvcState != "0")
                    {
                        throw new Exception("已确认的留言不能修改!");
                    }
                    oldbook.cnvcBook        = book.cnvcBook;
                    oldbook.cmvcPublishID   = book.cmvcPublishID;
                    oldbook.cnvcPublishName = book.cnvcPublishName;
                    oldbook.cndPublishDate  = dtSysTime;
                    oldbook.cnvcCheckDept   = book.cnvcCheckDept;

                    oldbook.cnvcCheckID   = string.Empty;
                    oldbook.cnvcCheckName = string.Empty;
                    oldbook.cndcheckDate  = DateTime.MinValue;

                    EntityMapping.Update(oldbook, trans);

                    operLog.cndOperDate  = dtSysTime;
                    operLog.cnvcComments = "留言本流水号:" + oldbook.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);
                }
            }
        }
Ejemplo n.º 5
0
        public static void AddProject(Project project, Oper oper)
        {
            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);

                    project.cnvcOperID  = oper.cnvcOperID;
                    project.cndOperDate = dtSysTime;
                    //project.cndCreateDate = dtSysTime;
                    project.cnnProjectID = Helper.GetSerialNo(trans);
                    project.cnvcIsSucess = "0";
                    if (project.cnvcMgr == oper.cnvcOperID || project.cnvcTradeMgr == oper.cnvcOperID)
                    {
                        project.cnvcProjectState = "P002";
                    }
                    else
                    {
                        project.cnvcProjectState = "P001";
                    }
                    EntityMapping.Create(project, trans);

                    BusiLog busiLog = new BusiLog();
                    busiLog.cndOperDate     = dtSysTime;
                    busiLog.cnnBusiSerialNo = Helper.GetSerialNo(trans);
                    busiLog.cnvcComments    = project.cnvcProjectName;
                    busiLog.cnvcFuncCode    = " 添加商机";
                    busiLog.cnvcOperID      = oper.cnvcOperID;
                    busiLog.cnvcIPAddress   = "";
                    EntityMapping.Create(busiLog, 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);
                }
            }
        }
Ejemplo n.º 6
0
        public static void BatchCustInfo(DataTable dt, Oper oper)
        {
            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);

                    foreach (DataRow dr in dt.Rows)
                    {
                        Cust cu = new Cust(dr);
                        cu.cnvcOperID  = oper.cnvcOperID;
                        cu.cndOperDate = dtSysTime;
                        //newOper.cndCreateDate = dtSysTime;
                        string strCount = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select count(*) from tbCust where cnnCustID = " + cu.cnnCustID + " or cnvcName='" + cu.cnvcName + "'").ToString();
                        if (Convert.ToInt32(strCount) > 0)
                        {
                            throw new Exception(cu.cnvcName + "已存在");
                        }

                        EntityMapping.Create(cu, trans);

                        BusiLog busiLog = new BusiLog();
                        busiLog.cndOperDate     = dtSysTime;
                        busiLog.cnnBusiSerialNo = Helper.GetSerialNo(trans);
                        busiLog.cnvcComments    = cu.cnvcName;
                        busiLog.cnvcFuncCode    = " 批量添加客户档案";
                        busiLog.cnvcOperID      = oper.cnvcOperID;
                        busiLog.cnvcIPAddress   = "";
                        EntityMapping.Create(busiLog, 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);
                }
            }
        }
Ejemplo n.º 7
0
        //减单
        public void OrderReduce(string strOrderSerialNo, string strReduceType, string strAddComments, DataTable dtOrderReduce, 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);

                    OrderSerialNo serialNo = new OrderSerialNo();
                    serialNo.cnvcFill    = "0";
                    serialNo.cnnSerialNo = Convert.ToDecimal(EntityMapping.Create(serialNo, trans));

                    foreach (DataRow drOrderReduce in dtOrderReduce.Rows)
                    {
                        OrderReduceLog orderReduce = new OrderReduceLog(drOrderReduce);
                        orderReduce.cnnOrderSerialNo   = decimal.Parse(strOrderSerialNo);
                        orderReduce.cnnReduceSerialNo  = serialNo.cnnSerialNo;
                        orderReduce.cnvcReduceType     = strReduceType;
                        orderReduce.cnvcReduceComments = strAddComments;
                        orderReduce.cndOperDate        = dtSysTime;
                        orderReduce.cnvcOperID         = operLog.cnvcOperID;
                        orderReduce.cnvcReduceState    = "0";
                        orderReduce.cnnReduceCount     = decimal.Parse(drOrderReduce["cnnOrderCount"].ToString());
                        EntityMapping.Create(orderReduce, trans);
                    }

                    operLog.cndOperDate  = dtSysTime;
                    operLog.cnvcComments = "订单流水:" + strOrderSerialNo;
                    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);
                }
            }
        }
Ejemplo n.º 8
0
        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);
                }
            }
        }
Ejemplo n.º 9
0
        public void BatchUpdateProduceCheck(ArrayList alCheck, string strProduceSerialNo, OperLog operLog)
        {
            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);

                    for (int i = 0; i < alCheck.Count; i++)
                    {
                        ProduceCheckLog check    = alCheck[i] as ProduceCheckLog;
                        ProduceCheckLog oldCheck = new ProduceCheckLog();
                        oldCheck.cnnProduceSerialNo = check.cnnProduceSerialNo;
                        oldCheck.cnvcCode           = check.cnvcCode;
                        oldCheck = EntityMapping.Get(oldCheck, trans) as ProduceCheckLog;
                        if (oldCheck == null)
                        {
                            throw new Exception("未找到指定产品生产库存");
                        }
                        oldCheck.cnnCheckCount = check.cnnCheckCount;
                        oldCheck.cnvcOperID    = check.cnvcOperID;
                        oldCheck.cndOperDate   = dtSysTime;
                        EntityMapping.Update(oldCheck, trans);
                    }

                    operLog.cndOperDate  = dtSysTime;
                    operLog.cnvcComments = "生产流水:" + strProduceSerialNo;
                    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);
                }
            }
        }
Ejemplo n.º 10
0
        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);
                }
            }
        }
Ejemplo n.º 11
0
        public int UpdateWareHouse(OperLog operLog, Entity.Warehouse wh)
        {
            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);

                    Entity.Warehouse oldwh = new AMSApp.zhenghua.Entity.Warehouse();
                    oldwh.cnvcWhCode = wh.cnvcWhCode;

                    oldwh                  = EntityMapping.Get(oldwh, trans) as AMSApp.zhenghua.Entity.Warehouse;
                    oldwh.cnvcWhName       = wh.cnvcWhName;
                    oldwh.cnvcDepCode      = wh.cnvcDepCode;
                    oldwh.cnvcWhAddress    = wh.cnvcWhAddress;
                    oldwh.cnvcWhPhone      = wh.cnvcWhPhone;
                    oldwh.cnvcWhPerson     = wh.cnvcWhPerson;
                    oldwh.cnvcWhValueStyle = wh.cnvcWhValueStyle;
                    oldwh.cnbFreeze        = wh.cnbFreeze;
                    oldwh.cnnFrequency     = wh.cnnFrequency;
                    oldwh.cnvcFrequency    = wh.cnvcFrequency;
                    oldwh.cnvcWhProperty   = wh.cnvcWhProperty;
                    oldwh.cnbShop          = wh.cnbShop;
                    EntityMapping.Update(oldwh, trans);

                    operLog.cndOperDate  = dtSysTime;
                    operLog.cnvcComments = "仓库编码:" + oldwh.cnvcWhCode;
                    EntityMapping.Create(operLog, trans);
                    trans.Commit();
                }
                catch (SqlException sex)
                {
                    trans.Rollback();
                    LogAdapter.WriteDatabaseException(sex);
                    return(-1);
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    LogAdapter.WriteFeaturesException(ex);
                    return(-1);
                }
                finally
                {
                    ConnectionPool.ReturnConnection(conn);
                }
                return(1);
            }
        }
Ejemplo n.º 12
0
        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);
                }
            }
        }
Ejemplo n.º 13
0
        public void AddOrder(OrderBook orderBook, DataTable dtOrderBookDetail, 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);

                    OrderSerialNo serialNo = new OrderSerialNo();
                    serialNo.cnvcFill    = "0";
                    serialNo.cnnSerialNo = Convert.ToDecimal(EntityMapping.Create(serialNo, trans));

                    orderBook.cnnOrderSerialNo = serialNo.cnnSerialNo;
                    orderBook.cndOrderDate     = dtSysTime;
                    orderBook.cnvcOrderOperID  = operLog.cnvcOperID;
                    EntityMapping.Create(orderBook, trans);
                    foreach (DataRow drOrderBookDetail in dtOrderBookDetail.Rows)
                    {
                        OrderBookDetail detail = new OrderBookDetail(drOrderBookDetail);
                        detail.cnnOrderSerialNo = serialNo.cnnSerialNo;
                        detail.cndOperDate      = dtSysTime;
                        detail.cnvcOperID       = operLog.cnvcOperID;
                        EntityMapping.Create(detail, trans);
                    }
                    operLog.cndOperDate  = dtSysTime;
                    operLog.cnvcComments = "订单流水:" + orderBook.cnnOrderSerialNo;
                    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);
                }
            }
        }
Ejemplo n.º 14
0
        public int DeleteComputationUnit(OperLog operLog, Entity.ComputationUnit cu)
        {
            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);

                    Entity.ComputationUnit oldcu = new Entity.ComputationUnit();
                    oldcu.cnvcComunitCode = cu.cnvcComunitCode;

                    oldcu = EntityMapping.Get(oldcu, trans)  as Entity.ComputationUnit;
                    if (oldcu == null)
                    {
                        throw new Exception("未找到记录单位");
                    }
                    if (oldcu.cnbMainUnit)
                    {
                        throw new Exception("主计量单位不能删除");
                    }
                    EntityMapping.Delete(oldcu, trans);

                    operLog.cndOperDate  = dtSysTime;
                    operLog.cnvcComments = "计量单位组编码:" + cu.cnvcComunitCode;
                    EntityMapping.Create(operLog, trans);
                    trans.Commit();
                }
                catch (SqlException sex)
                {
                    trans.Rollback();
                    LogAdapter.WriteDatabaseException(sex);
                    return(-1);
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    LogAdapter.WriteFeaturesException(ex);
                    return(-1);
                }
                finally
                {
                    ConnectionPool.ReturnConnection(conn);
                }
                return(1);
            }
        }
Ejemplo n.º 15
0
        public static void UpdatePwd(Oper oper)
        {
            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);

                    Oper oldOper = new Oper();
                    oldOper.cnvcOperID = oper.cnvcOperID;
                    oldOper            = EntityMapping.Get(oldOper, trans) as Oper;
                    if (null == oldOper)
                    {
                        throw new Exception("无此用户");
                    }
                    oldOper.cnvcOperPwd = oper.cnvcOperPwd;                    //DataSecurity.Encrypt(oper.cnvcOperPwd);
                    EntityMapping.Update(oldOper, trans);

                    BusiLog busiLog = new BusiLog();
                    busiLog.cndOperDate     = dtSysTime;
                    busiLog.cnnBusiSerialNo = Helper.GetSerialNo(trans);
                    busiLog.cnvcComments    = "修改密码";
                    busiLog.cnvcFuncCode    = "修改密码";
                    busiLog.cnvcOperID      = oper.cnvcOperID;
                    busiLog.cnvcIPAddress   = "";
                    EntityMapping.Create(busiLog, 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);
                }
            }
        }
Ejemplo n.º 16
0
/// <summary>
/// 专供油合同修改
/// </summary>
/// <param name="so">合同对象</param>
/// <param name="bl">日志</param>
        public void SOMOD(Entity.SpecialOilDept so, Entity.BusiLog bl)
        {
            ConnectionPool.IsCenter = true;
            using (SqlConnection conn = ConnectionPool.BorrowConnection())
            {
                //conn.Open();
                SqlTransaction trans = conn.BeginTransaction(IsolationLevel.ReadCommitted);
                try
                {
                    string   strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString();
                    DateTime dtSysTime  = DateTime.Parse(strSysTime);
                    Guid     gd         = Guid.NewGuid();

                    EntityMapping.Update(so, trans);
                    //日志
                    bl.cnnSerial    = gd;
                    bl.cnvcComments = "专供油合同修改";
                    bl.cnvcOperType = OperType.OP205;
                    bl.cndOperDate  = dtSysTime;
                    bl.cnvcSource   = InSource.cs;
                    EntityMapping.Create(bl, trans);

                    trans.Commit();
                }
                catch (BusinessException bex)
                {
                    trans.Rollback();
                    LogAdapter.WriteBusinessException(bex);
                    throw bex;
                }
                catch (SqlException sex)
                {
                    trans.Rollback();
                    LogAdapter.WriteDatabaseException(sex);
                    throw sex;
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    LogAdapter.WriteFeaturesException(ex);
                    throw ex;
                }
                finally
                {
                    ConnectionPool.ReturnConnection(conn);
                }
            }
        }
Ejemplo n.º 17
0
        //订单更新产品
        public void UpdateDetail(OrderBookDetail detail, 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);

                    OrderBookDetail oldDetail = new OrderBookDetail();
                    oldDetail.cnnOrderSerialNo = detail.cnnOrderSerialNo;
                    oldDetail.cnvcProductCode  = detail.cnvcProductCode;
                    oldDetail = EntityMapping.Get(oldDetail, trans) as OrderBookDetail;

                    oldDetail.cnnOrderCount = detail.cnnOrderCount;
                    oldDetail.cnnSum        = detail.cnnOrderCount * oldDetail.cnnPrice;
                    oldDetail.cnvcOperID    = detail.cnvcOperID;
                    oldDetail.cndOperDate   = dtSysTime;
                    EntityMapping.Update(oldDetail, trans);

                    operLog.cndOperDate  = dtSysTime;
                    operLog.cnvcComments = "订单流水:" + detail.cnnOrderSerialNo.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);
                }
            }
        }
Ejemplo n.º 18
0
        public void UpdatePriority(Dept dept, OperLog operLog)
        {
            using (SqlConnection conn = ConnectionPool.BorrowConnection())
            {
                //conn.Open();

                SqlTransaction trans = conn.BeginTransaction();
                try
                {
                    Dept oldDept = new Dept();
                    oldDept.cnvcDeptID = dept.cnvcDeptID;
                    oldDept            = EntityMapping.Get(oldDept, trans) as Dept;
                    if (oldDept == null)
                    {
                        throw new Exception("未找到相应的部门");
                    }
                    oldDept.cnnPriority = dept.cnnPriority;
                    EntityMapping.Update(oldDept, trans);

                    string   strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString();
                    DateTime dtSysTime  = DateTime.Parse(strSysTime);

                    operLog.cndOperDate  = dtSysTime;
                    operLog.cnvcComments = "部门ID:" + dept.cnvcDeptID;
                    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);
                }
            }
        }
Ejemplo n.º 19
0
        public int UpdateProductClass(OperLog operLog, ProductClass pc)
        {
            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);

                    ProductClass oldpc = new ProductClass();
                    oldpc.cnvcProductClassCode = pc.cnvcProductClassCode;

                    oldpc = EntityMapping.Get(oldpc, trans) as ProductClass;
                    oldpc.cnvcComments         = pc.cnvcComments;
                    oldpc.cnvcProductClassName = pc.cnvcProductClassName;
                    oldpc.cnvcProductType      = pc.cnvcProductType;
                    EntityMapping.Update(pc, trans);

                    operLog.cndOperDate  = dtSysTime;
                    operLog.cnvcComments = "产品分类:" + pc.cnvcProductClassCode;
                    EntityMapping.Create(operLog, trans);
                    trans.Commit();
                }
                catch (SqlException sex)
                {
                    trans.Rollback();
                    LogAdapter.WriteDatabaseException(sex);
                    return(-1);
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    LogAdapter.WriteFeaturesException(ex);
                    return(-1);
                }
                finally
                {
                    ConnectionPool.ReturnConnection(conn);
                }
                return(1);
            }
        }
Ejemplo n.º 20
0
 public static void AddDept(Dept dept, BusiLog busiLog)
 {
     try
     {
         BusinessRules.SysManage.Authorization auth = new BusinessRules.SysManage.Authorization();
         auth.AddDept(dept, busiLog);
     }
     catch (SqlException sex)
     {
         LogAdapter.WriteDatabaseException(sex);
         throw new Exception("数据库访问异常。");
     }
     catch (Exception ex)
     {
         LogAdapter.WriteFeaturesException(ex);
         throw new Exception("业务规则层异常。");
     }
 }
Ejemplo n.º 21
0
 public static void UpdateCompany(MebCompanyPrepay company, BusiLog busiLog)
 {
     try
     {
         BusinessRules.Prepay.PrepayFee prepay = new BusinessRules.Prepay.PrepayFee();
         prepay.UpdateCompany(company, busiLog);
     }
     catch (SqlException sex)
     {
         LogAdapter.WriteDatabaseException(sex);
         throw new Exception("数据库访问异常。");
     }
     catch (Exception ex)
     {
         LogAdapter.WriteFeaturesException(ex);
         throw new Exception("业务规则层异常。");
     }
 }
Ejemplo n.º 22
0
 public static void AddFee(FillFee fee, BusiLog busiLog)
 {
     try
     {
         BusinessRules.Prepay.PrepayFee prepay = new BusinessRules.Prepay.PrepayFee();
         prepay.AddFee(fee, busiLog);
     }
     catch (SqlException sex)
     {
         LogAdapter.WriteDatabaseException(sex);
         throw new Exception("数据库访问异常。");
     }
     catch (Exception ex)
     {
         LogAdapter.WriteFeaturesException(ex);
         throw new Exception("业务规则层异常。");
     }
 }
Ejemplo n.º 23
0
 public static void DeleteSpecialOilDept(SpecialOilDept specialOilDept, BusiLog busiLog)
 {
     try
     {
         BusinessRules.SysManage.SpecialOil specialOil = new BusinessRules.SysManage.SpecialOil();
         specialOil.DeleteSpecialOilDept(specialOilDept, busiLog);
     }
     catch (SqlException sex)
     {
         LogAdapter.WriteDatabaseException(sex);
         throw new Exception("数据库访问异常。");
     }
     catch (Exception ex)
     {
         LogAdapter.WriteFeaturesException(ex);
         throw new Exception("业务规则层异常。");
     }
 }
Ejemplo n.º 24
0
        public static void InitPwd(Oper oldOper, Oper oper)
        {
            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);

                    //EntityMapping.Delete(oldOper,trans);

                    SqlHelper.ExecuteNonQuery(trans, CommandType.Text, "update tbOper set cnvcOperPwd='" + DataSecurity.Encrypt("123456") + "' where cnvcOperID='" + oldOper.cnvcOperID + "'");

                    BusiLog busiLog = new BusiLog();
                    busiLog.cndOperDate     = dtSysTime;
                    busiLog.cnnBusiSerialNo = Helper.GetSerialNo(trans);
                    //busiLog.cnvcComments = oldOper.cnvcOperName;
                    busiLog.cnvcFuncCode  = "初始密码";
                    busiLog.cnvcOperID    = oper.cnvcOperID;
                    busiLog.cnvcIPAddress = "";
                    EntityMapping.Create(busiLog, 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);
                }
            }
        }
Ejemplo n.º 25
0
        public int UpdateComputationGroup(OperLog operLog, ComputationGroup cg)
        {
            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);

                    ComputationGroup oldcg = new ComputationGroup();
                    oldcg.cnvcGroupCode = cg.cnvcGroupCode;

                    oldcg = EntityMapping.Get(oldcg, trans) as ComputationGroup;
                    oldcg.cnvcGroupName = cg.cnvcGroupName;
                    EntityMapping.Update(cg, trans);

                    operLog.cndOperDate  = dtSysTime;
                    operLog.cnvcComments = "计量单位组编码:" + cg.cnvcGroupCode;
                    EntityMapping.Create(operLog, trans);
                    trans.Commit();
                }
                catch (SqlException sex)
                {
                    trans.Rollback();
                    LogAdapter.WriteDatabaseException(sex);
                    return(-1);
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    LogAdapter.WriteFeaturesException(ex);
                    return(-1);
                }
                finally
                {
                    ConnectionPool.ReturnConnection(conn);
                }
                return(1);
            }
        }
Ejemplo n.º 26
0
        public static void DeleteOperFunc(OperFunc operFunc, Oper oper)
        {
            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);

                    EntityMapping.Delete(operFunc, trans);


                    BusiLog busiLog = new BusiLog();
                    busiLog.cndOperDate     = dtSysTime;
                    busiLog.cnnBusiSerialNo = Helper.GetSerialNo(trans);
                    busiLog.cnvcComments    = operFunc.cnvcFuncCode;
                    busiLog.cnvcFuncCode    = "删除权限";
                    busiLog.cnvcOperID      = oper.cnvcOperID;
                    busiLog.cnvcIPAddress   = "";
                    EntityMapping.Create(busiLog, 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);
                }
            }
        }
Ejemplo n.º 27
0
        public int UpdateProducer(OperLog operLog, Entity.Producer producer)
        {
            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);

                    Entity.Producer oldproducer = new AMSApp.zhenghua.Entity.Producer();
                    oldproducer.cnnProducerID = producer.cnnProducerID;

                    oldproducer = EntityMapping.Get(oldproducer, trans) as AMSApp.zhenghua.Entity.Producer;
                    oldproducer.cnvcProducerName = producer.cnvcProducerName;
                    EntityMapping.Update(oldproducer, trans);

                    operLog.cndOperDate  = dtSysTime;
                    operLog.cnvcComments = "生产员编码:" + oldproducer.cnnProducerID.ToString();
                    EntityMapping.Create(operLog, trans);
                    trans.Commit();
                }
                catch (SqlException sex)
                {
                    trans.Rollback();
                    LogAdapter.WriteDatabaseException(sex);
                    return(-1);
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    LogAdapter.WriteFeaturesException(ex);
                    return(-1);
                }
                finally
                {
                    ConnectionPool.ReturnConnection(conn);
                }
                return(1);
            }
        }
Ejemplo n.º 28
0
        public int UpdateBOM(OperLog operLog, string strinvcode, DataTable dtbom)
        {
            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);

                    //string strinvcode = "";
                    SqlHelper.ExecuteNonQuery(trans, CommandType.Text, "delete from tbbillofmaterials where cnvcpartinvcode='" + strinvcode + "'");
                    foreach (DataRow drbom in dtbom.Rows)
                    {
                        Entity.BillOfMaterials bom = new BillOfMaterials(drbom);
                        EntityMapping.Create(bom, trans);
                    }
                    operLog.cndOperDate  = dtSysTime;
                    operLog.cnvcComments = "存货编码:" + strinvcode;
                    EntityMapping.Create(operLog, trans);
                    trans.Commit();
                }
                catch (SqlException sex)
                {
                    trans.Rollback();
                    LogAdapter.WriteDatabaseException(sex);
                    return(-1);
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    LogAdapter.WriteFeaturesException(ex);
                    return(-1);
                }
                finally
                {
                    ConnectionPool.ReturnConnection(conn);
                }
                return(1);
            }
        }
Ejemplo n.º 29
0
        public static void UpdateVCust(Cust newcust, Oper oper)
        {
            using (SqlConnection conn = ConnectionPool.BorrowConnection())
            {
                //conn.Open();

                SqlTransaction trans = conn.BeginTransaction();
                try
                {
                    DateTime dtSysTime = Helper.GetSysTime(trans);
                    newcust.cndCreateDate = dtSysTime;
                    newcust.cndOperDate   = dtSysTime;
                    EntityMapping.Update(newcust, trans);

                    BusiLog busiLog = new BusiLog();
                    busiLog.cndOperDate     = dtSysTime;
                    busiLog.cnnBusiSerialNo = Helper.GetSerialNo(trans);
                    busiLog.cnvcComments    = "修改大客户信息";
                    busiLog.cnvcFuncCode    = " 客户档案管理";
                    busiLog.cnvcOperID      = oper.cnvcOperID;
                    busiLog.cnvcIPAddress   = "";
                    EntityMapping.Create(busiLog, 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);
                }
            }
        }
Ejemplo n.º 30
0
        public int DeleteInventory(OperLog operLog, Entity.Inventory inv)
        {
            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);

                    Entity.Inventory oldinv = new Entity.Inventory();
                    oldinv.cnvcInvCode = inv.cnvcInvCode;

                    oldinv = EntityMapping.Get(oldinv, trans)  as Entity.Inventory;
                    EntityMapping.Delete(oldinv, trans);

                    operLog.cndOperDate  = dtSysTime;
                    operLog.cnvcComments = "存货编码:" + inv.cnvcInvCode;
                    EntityMapping.Create(operLog, trans);
                    trans.Commit();
                }
                catch (SqlException sex)
                {
                    trans.Rollback();
                    LogAdapter.WriteDatabaseException(sex);
                    return(-1);
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    LogAdapter.WriteFeaturesException(ex);
                    return(-1);
                }
                finally
                {
                    ConnectionPool.ReturnConnection(conn);
                }
                return(1);
            }
        }