Пример #1
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);
                }
            }
        }
Пример #2
0
        public void BOMMOD(Entity.BillOfMaterials bom, Entity.BusiLog bl, bool isHis)
        {
            ConnectionPool.IsCenter = false;
            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);

                    Entity.OilStorage os = new OilStorage(bl.ToTable());
                    os.cnvcGoodsName = bom.cnvcGoodsName;
                    os.cnvcGoodsType = bom.cnvcGoodsType;
                    os = EntityMapping.Get(os, trans) as OilStorage;
                    if (null == os)
                    {
                        throw new BusinessException(bexType.noobject, "库存获取错误");
                    }

                    Guid gd = Guid.NewGuid();

                    //判断修改操作类型 改多为入库 改少为出库
                    //专供油出库
                    Entity.BillOfMaterials oldbom = new BillOfMaterials(bom.GetOriginalValue());
                    string strOperType            = "";
                    if (oldbom.cnnCount > bom.cnnCount)
                    {
                        strOperType = InType.BOMModIn;
                    }
                    else
                    {
                        strOperType = InType.BOMModOut;
                    }

                    //验收单
                    //bom.cnvcInType = strOperType;
                    bom.cndOperDate = dtSysTime;
                    if (isHis)
                    {
                        Entity.BillOfMaterialsHis bomhis = new BillOfMaterialsHis(bom.GetOriginalValue());
                        EntityMapping.Delete(bomhis, trans);

                        //bomhis.SynchronizeModifyValue(bom);
                        EntityMapping.Create(bom, trans);
                    }
                    else
                    {
                        EntityMapping.Update(bom, trans);
                    }
                    if (bom.cnnCount != oldbom.cnnCount)
                    {
                        //库存日志
                        Entity.OilStorageLog ol = new OilStorageLog(bom.ToTable());
                        ol.cnvcDeptName  = bl.cnvcDeptName;
                        ol.cnvcOperType  = strOperType;
                        ol.cnnSerial     = gd;
                        ol.cnnLastCount  = os.cnnStorageCount;
                        ol.cnnInOutCount = oldbom.cnnCount - bom.cnnCount;                      //bom.cnnCount-oldbom.cnnCount;
                        ol.cnnCurCount   = os.cnnStorageCount + oldbom.cnnCount - bom.cnnCount;
                        EntityMapping.Create(ol, trans);

                        //库存
                        os.cnnStorageCount = ol.cnnCurCount;
                        EntityMapping.Update(os, trans);
                    }
                    //日志
                    bl.cnnSerial    = gd;
                    bl.cnvcComments = "领料单修改,出入库量:" + (oldbom.cnnCount - bom.cnnCount);
                    bl.cnvcOperType = OperType.OP203;
                    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);
                }
            }
        }
Пример #3
0
        //重算

        public static void AgainComp(string strBeginDate, string strEndDate, BusiLog bl)
        {
            //ConnectionPool.IsCenter = false;
            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);

                    string    strsql     = "select * from tbConsItem where CONVERT(varchar(10),cndconsdate,121) between '" + strBeginDate + "' and '" + strEndDate + "'";
                    DataTable dtConsItem = SqlHelper.ExecuteDataTable(trans, CommandType.Text, strsql);
                    if (dtConsItem.Rows.Count == 0)
                    {
                        throw new BusinessException("业务异常", "没有需要更新的消费记录!");
                    }
                    strsql = "select * from tbOilPrice where convert(varchar(10),cndpricedate,121) <= '" + strEndDate + "' order by cndPriceDate desc";
                    DataTable dtPrice = SqlHelper.ExecuteDataTable(trans, CommandType.Text, strsql);
                    if (dtPrice.Rows.Count == 0)
                    {
                        throw new BusinessException("业务异常", "没有需要更新的油价!");
                    }
                    foreach (DataRow dr in dtConsItem.Rows)
                    {
                        ConsItem ci = new ConsItem(dr);

                        DataRow[] drPrices = dtPrice.Select("cnvcGoodsName='" + ci.cnvcGoodsName + "' and cnvcGoodsType='" + ci.cnvcGoodsType + "' and cnvcUnit='KG' and cnvcDeptName='" + ci.cnvcDeptName + "' and cndpricedate<= '" + ci.cndConsDate.AddDays(1).ToString("yyyy-MM-dd") + "'", "cndPriceDate desc");
                        if (drPrices.Length == 0)
                        {
                            continue;
                        }
                        OilPrice op   = new OilPrice(drPrices[0]);
                        decimal  dFee = ci.cnnKGCount * op.cnnOilPrice;

                        if (ci.cnnPrice != op.cnnOilPrice && ci.cnnFee != dFee)
                        {
                            ConsItemHis cih = new ConsItemHis(ci.ToTable());
                            cih.cnnSerial    = Guid.NewGuid();
                            cih.cndOperDate  = dtSysTime;
                            cih.cnvcOperName = bl.cnvcOperName;
                            cih.cnvcComments = "|cnnSerial=" + ci.cnnSerial.ToString();


                            ci.cnnPrice     = op.cnnOilPrice;
                            ci.cnnFee       = dFee;
                            ci.cnvcComments = "老油价:" + cih.cnnPrice.ToString() + ",新油价:" + ci.cnnPrice.ToString();

                            decimal dAddFee = cih.cnnFee - dFee;

                            BusiLog busiLog = new BusiLog();
                            busiLog.cndOperDate  = dtSysTime;
                            busiLog.cnnSerial    = Guid.NewGuid();
                            busiLog.cnvcOperName = bl.cnvcOperName;
                            busiLog.cnvcComments = "油价补差充值:" + ci.cnvcCardID + "|" + dAddFee.ToString();
                            busiLog.cnvcDeptID   = bl.cnvcDeptID;
                            busiLog.cnvcDeptName = bl.cnvcDeptName;
                            busiLog.cnvcOperType = "BS012";
                            busiLog.cnvcSource   = "网站";

//							FillFee fee = new FillFee();
//							fee.cndOperDate = dtSysTime;
//							fee.cnnFillFee = dAddFee;
//							fee.cnnSerial = busiLog.cnnSerial;
//							fee.cnvcAcctID = ci.cnvcAcctID;
//							fee.cnvcCompanyID = ci.cnvcCompanyID;
//							fee.cnvcCompanyName = ci.cnvcCompanyName;
//							fee.cnvcDeptID = ci.cnvcDeptID;
//							fee.cnvcDeptName = ci.cnvcDeptName;
//							fee.cnvcOperName = bl.cnvcOperName;

                            SqlHelper.ExecuteNonQuery(trans, CommandType.Text, "update tbMebCompanyPrepay set cnnPrepayFee = cnnPrepayFee+" + dAddFee.ToString() + " where cnvcCompanyID='" + ci.cnvcCompanyID + "'");
                            //EntityMapping.Create(fee,trans);
                            EntityMapping.Create(busiLog, trans);

                            EntityMapping.Create(cih, trans);
                            EntityMapping.Update(ci, trans);
                        }
                    }
                    //日志
                    bl.cnnSerial   = Guid.NewGuid();
                    bl.cndOperDate = dtSysTime;
                    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);
                }
            }
        }
Пример #4
0
        public static void UpdateBOS(BillOfOutStorage bos, BusiLog bl)
        {
            //ConnectionPool.IsCenter = false;
            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);

                    Dept dept = new Dept();
                    dept.cnvcDeptID = bos.cnvcDeptID;
                    dept            = EntityMapping.Get(dept, trans) as Dept;

                    OilStorage os = new OilStorage();
                    os.cnvcGoodsName = bos.cnvcGoodsName;
                    os.cnvcGoodsType = bos.cnvcGoodsType;
                    os.cnvcDeptID    = bos.cnvcDeptID;
                    os = EntityMapping.Get(os, trans) as OilStorage;
                    if (null == os)
                    {
                        throw new BusinessException(bexType.noobject, "库存获取错误");
                    }

                    Guid gd = Guid.NewGuid();

                    //判断修改操作类型 改多为入库 改少为出库
                    BillOfOutStorage oldbos = new BillOfOutStorage();
                    oldbos.cnvcBillNo = bos.cnvcBillNo;
                    oldbos.cnvcDeptID = bos.cnvcDeptID;
                    oldbos            = EntityMapping.Get(oldbos, trans) as BillOfOutStorage;

                    string strOperType = "";
                    if (oldbos.cnnCount > bos.cnnCount)
                    {
                        strOperType = OutType.BOSIn;
                    }
                    else
                    {
                        strOperType = OutType.BOSOut;
                    }

                    //验收单

                    if (bos.cnnCount != oldbos.cnnCount)
                    {
                        //库存日志
                        OilStorageLog ol = new OilStorageLog(bos.ToTable());
                        ol.cnvcDeptName  = dept.cnvcDeptName;
                        ol.cndOperDate   = dtSysTime;
                        ol.cnvcOperType  = strOperType;
                        ol.cnnSerial     = gd;
                        ol.cnnLastCount  = oldbos.cnnCount;                   //os.cnnStorageCount;
                        ol.cnnInOutCount = oldbos.cnnCount - bos.cnnCount;    //bos.cnnCount-oldbos.cnnCount;
                        ol.cnnCurCount   = bos.cnnCount;                      //os.cnnStorageCount + oldbos.cnnCount-bos.cnnCount ;
                        EntityMapping.Create(ol, trans);

                        OilStorageLogHis olhis = new OilStorageLogHis(ol.ToTable());
                        EntityMapping.Create(olhis, trans);

                        oldbos.SynchronizeModifyValue(bos);
                        oldbos.cnnCount           = bos.cnnCount;
                        oldbos.cnnReceivableCount = bos.cnnReceivableCount;
                        oldbos.cnvcOutType        = strOperType;
                        EntityMapping.Update(oldbos, trans);
                        //库存
                        os.cnnStorageCount = os.cnnStorageCount + ol.cnnInOutCount;                      //ol.cnnCurCount;
                        EntityMapping.Update(os, trans);
                    }
                    //日志
                    bl.cnnSerial    = gd;
                    bl.cnvcComments = "出库单修改,出入库量:" + (oldbos.cnnCount - bos.cnnCount);                //(bos.cnnCount-oldbos.cnnCount);
                    bl.cnvcOperType = OperType.OP202;
                    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);
                }
            }
        }
Пример #5
0
        /// <summary>
        /// 仅下载
        /// </summary>
        /// <returns></returns>
        public int SystemStartParaDownLoad()
        {
            int icount = 0;

            try
            {
                DataSet ds = new DataSet();
                ConnectionPool.IsCenter = true;
                using (SqlConnection conn = ConnectionPool.BorrowConnection())
                {
                    //conn.Open();

                    //SqlTransaction trans = conn.BeginTransaction();
                    try
                    {
                        foreach (string strtable in ConstApp.SystemParaTables.Split(':'))
                        {
                            string[] strtables = strtable.Split(',');
                            string   strsql    = "select * from " + strtables[0] + " where 1=1";
                            if (strtables[3] != "")
                            {
                                strsql += " and " + strtables[3];
                            }
                            DataTable dt =                             //SingleTableQuery.ExcuteQuery(strtables[0],conn);
                                           SqlHelper.ExecuteDataTable(conn, CommandType.Text, strsql);
                            dt.TableName = strtables[0];
                            if (strtables.Length > 1 && strtables[1] != "")
                            {
                                if (!(dt.Rows.Count > Convert.ToInt32(strtables[1])))
                                {
                                    throw new BusinessException(bexType.centerNoPara, "中心表:" + strtables[0] + "参数不全!");
                                }
                            }
                            ds.Tables.Add(dt);
                        }
                    }
                    catch (BusinessException 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);
                    }
                }
                ConnectionPool.IsCenter = false;
                using (SqlConnection conn = ConnectionPool.BorrowConnection())
                {
                    //conn.Open();
                    SqlTransaction trans = conn.BeginTransaction(IsolationLevel.ReadCommitted);
                    try
                    {
                        foreach (string strtable in ConstApp.SystemParaTables.Split(':'))
                        {
                            string[] strtables = strtable.Split(',');
                            if (strtables[0].ToUpper() == "TBDEPT")
                            {
                                string      strupdatesql = "select * from tbdept where cnvcLocalFlag='LOCAL'";
                                DataTable   dtLocal      = SqlHelper.ExecuteDataTable(trans, CommandType.Text, strupdatesql);
                                Entity.Dept deptLocal    = new Dept(dtLocal);
                                DataTable   dtCenter     = ds.Tables[strtables[0]];
                                DataRow[]   drCenters    = dtCenter.Select("cnvcdeptid='" + deptLocal.cnvcDeptID + "'");
                                if (drCenters.Length > 0)
                                {
                                    drCenters[0]["cnvcLocalFlag"] = deptLocal.cnvcLocalFlag;
                                }
                            }
                            //清理表
                            int idelcount = SqlHelper.ExecuteNonQuery(trans, CommandType.Text, "truncate table " + strtables[0]);
                            //插入记录
                            DataTable dt = ds.Tables[strtables[0]];
                            foreach (DataRow dr in dt.Rows)
                            {
                                Type t = Type.GetType(strtables[2]);
                                EntityBase.EntityObjectBase eo = Activator.CreateInstance(t, new object[] { dr }) as EntityBase.EntityObjectBase;
                                EntityMapping.Create(eo, trans);
                                icount += 1;
                            }
                        }
                        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);
                    }
                }
            }
            catch (BusinessException bex)
            {
                throw bex;
            }
            catch (SqlException sex)
            {
                throw sex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(icount);
        }
Пример #6
0
        public void SOSync(string strDeptName)
        {
            ConnectionPool.IsCenter = true;
            DataTable dtCenter = null;
            string    strsql   = "select * from tbSpecialOilDept where cnvcdeliverycompany like '" + strDeptName + "%'";

            using (SqlConnection conn = ConnectionPool.BorrowConnection())
            {
                //conn.Open();
                //SqlTransaction trans = conn.BeginTransaction(IsolationLevel.ReadCommitted);
                try
                {
                    dtCenter = SqlHelper.ExecuteDataTable(conn, CommandType.Text, strsql);
                }
                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);
                }
            }


            ConnectionPool.IsCenter = false;
            using (SqlConnection conn = ConnectionPool.BorrowConnection())
            {
                //conn.Open();
                SqlTransaction trans = conn.BeginTransaction(IsolationLevel.ReadCommitted);
                try
                {
                    DataTable dtLocal = SqlHelper.ExecuteDataTable(trans, CommandType.Text, strsql);
                    foreach (DataRow dr in dtCenter.Rows)
                    {
                        Entity.SpecialOilDept so  = new SpecialOilDept(dr);
                        DataRow[]             drs = dtLocal.Select("cnvcContractNo='" + so.cnvcContractNo + "'");
                        if (drs.Length > 0)
                        {
                            Entity.SpecialOilDept oldso = new SpecialOilDept(drs[0]);
                            so.SynchronizeModifyValue(oldso);
                            EntityMapping.Update(so, trans);
                        }
                        else
                        {
                            EntityMapping.Create(so, 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);
                }
            }
        }