Beispiel #1
0
        /// <summary>
        /// 删除销售订单
        /// </summary>
        /// <param name="SaleOrderID"></param>
        /// <returns></returns>
        public bool Delete(string SaleOrderID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("delete from SaleOrder ");
            strSql.Append(" where SaleOrderID=@SaleOrderID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SaleOrderID", SqlDbType.VarChar, 36)
            };
            parameters[0].Value = SaleOrderID;

            int rows = 0;

            IDbTransaction transaction = DBAccess.BeginDbTransaction(DB.Type, DB.ConnectionString);

            try
            {
                //删除分录
                SaleOrderItemDAL item = new SaleOrderItemDAL();
                item.Delete(SaleOrderID);

                //删除分阅人
                SOReaderDAL sor = new SOReaderDAL();
                sor.Delete(SaleOrderID);

                //删除复核人
                SOSecondCheckDAL sos = new SOSecondCheckDAL();
                sos.Delete(SaleOrderID);

                rows = DBAccess.ExecuteNonQuery(DB.Type, DB.ConnectionString, CommandType.Text, strSql.ToString(), parameters);

                transaction.Commit();
            }
            catch
            {
                transaction.Rollback();
            }

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 取消提交
        /// </summary>
        /// <param name="SaleOrderID">单据ID</param>
        /// <returns></returns>
        public bool UnSubmit(string SaleOrderID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SaleOrder set ");
            strSql.Append("SaleState='1',");
            strSql.Append("FirstChecker='',");
            strSql.Append("FirstCheckView='',");
            strSql.Append("SecondCheckerName='',");
            strSql.Append("ReaderName=''");
            strSql.Append(" where SaleOrderID=@SaleOrderID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SaleOrderID", SqlDbType.VarChar, 36)
            };
            parameters[0].Value = SaleOrderID;

            IDbTransaction transaction = DBAccess.BeginDbTransaction(DB.Type, DB.ConnectionString);

            try
            {
                DBAccess.ExecuteNonQuery(DB.Type, DB.ConnectionString, CommandType.Text, strSql.ToString(), parameters);

                SOSecondCheckDAL soSC = new SOSecondCheckDAL();
                soSC.Delete(SaleOrderID);

                SOReaderDAL rSC = new SOReaderDAL();
                rSC.Delete(SaleOrderID);

                transaction.Commit();
                return(true);
            }
            catch
            {
                transaction.Rollback();
            }
            return(false);
        }
Beispiel #3
0
        /// <summary>
        /// 新增销售订单
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int AddSaleOrder(SaleOrder model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SaleOrder(");
            strSql.Append("SaleOrderID,SaleOrderCode,BillTypeID,MaterialID,SaleUnitID,ClientID,SaleDate,SaleQty,SalePrice,SaleCost,FinishDate,Creator,CreateTime,Editor,EditTime,FirstChecker,FirstCheckTime,FirstCheckView,RoutingID,SaleState,Remark,SecondCheckerName,ReaderName,Routing)");
            strSql.Append(" values (");
            strSql.Append("@SaleOrderID,@SaleOrderCode,@BillTypeID,@MaterialID,@SaleUnitID,@ClientID,@SaleDate,@SaleQty,@SalePrice,@SaleCost,@FinishDate,@Creator,@CreateTime,@Editor,@EditTime,@FirstChecker,@FirstCheckTime,@FirstCheckView,@RoutingID,@SaleState,@Remark,@SecondCheckerName,@ReaderName,@Routing)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SaleOrderID",       SqlDbType.VarChar,     36),
                new SqlParameter("@SaleOrderCode",     SqlDbType.VarChar,     60),
                new SqlParameter("@BillTypeID",        SqlDbType.VarChar,     36),
                new SqlParameter("@MaterialID",        SqlDbType.VarChar,     36),
                new SqlParameter("@SaleUnitID",        SqlDbType.VarChar,     36),
                new SqlParameter("@ClientID",          SqlDbType.VarChar,     36),
                new SqlParameter("@SaleDate",          SqlDbType.Char,         8),
                new SqlParameter("@SaleQty",           SqlDbType.Decimal,     13),
                new SqlParameter("@SalePrice",         SqlDbType.Decimal,     13),
                new SqlParameter("@SaleCost",          SqlDbType.Decimal,     13),
                new SqlParameter("@FinishDate",        SqlDbType.Char,         8),
                new SqlParameter("@Creator",           SqlDbType.VarChar,     36),
                new SqlParameter("@CreateTime",        SqlDbType.DateTime),
                new SqlParameter("@Editor",            SqlDbType.VarChar,     36),
                new SqlParameter("@EditTime",          SqlDbType.DateTime),
                new SqlParameter("@FirstChecker",      SqlDbType.VarChar,     36),
                new SqlParameter("@FirstCheckTime",    SqlDbType.DateTime),
                new SqlParameter("@FirstCheckView",    SqlDbType.VarChar,    255),
                new SqlParameter("@RoutingID",         SqlDbType.VarChar,     36),
                new SqlParameter("@SaleState",         SqlDbType.Char,         1),
                new SqlParameter("@Remark",            SqlDbType.VarChar,   1024),
                new SqlParameter("@SecondCheckerName", SqlDbType.VarChar,    255),
                new SqlParameter("@ReaderName",        SqlDbType.VarChar,    255),
                new SqlParameter("@Routing",           SqlDbType.VarChar, 1024)
            };
            parameters[0].Value  = model.SaleOrderID;
            parameters[1].Value  = model.SaleOrderCode;
            parameters[2].Value  = model.BillTypeID;
            parameters[3].Value  = model.MaterialID;
            parameters[4].Value  = model.SaleUnitID;
            parameters[5].Value  = model.ClientID;
            parameters[6].Value  = model.SaleDate;
            parameters[7].Value  = model.SaleQty;
            parameters[8].Value  = model.SalePrice;
            parameters[9].Value  = model.SaleCost;
            parameters[10].Value = model.FinishDate;
            parameters[11].Value = model.Creator;
            parameters[12].Value = model.CreateTime;
            parameters[13].Value = model.Editor;
            parameters[14].Value = model.EditTime;
            parameters[15].Value = model.FirstChecker;
            parameters[16].Value = model.FirstCheckTime;
            parameters[17].Value = model.FirstCheckView;
            parameters[18].Value = model.RoutingID;
            parameters[19].Value = model.SaleState;
            parameters[20].Value = model.Remark;
            parameters[21].Value = model.SecondCheckerName;
            parameters[22].Value = model.ReaderName;
            parameters[23].Value = model.Routing;

            IDbTransaction transaction = DBAccess.BeginDbTransaction(DB.Type, DB.ConnectionString);

            try
            {
                DBAccess.ExecuteNonQuery(DB.Type, DB.ConnectionString, CommandType.Text, strSql.ToString(), parameters);

                SOSecondCheckDAL soSC = new SOSecondCheckDAL();
                int socount           = model.SOList.Count;
                if (socount > 0)
                {
                    for (int i = 0; i < socount; i++)
                    {
                        SOSecondCheck sosc = model.SOList[i] as SOSecondCheck;
                        soSC.Add(sosc);
                    }
                }

                SOReaderDAL rSC    = new SOReaderDAL();
                int         rcount = model.RList.Count;
                if (rcount > 0)
                {
                    for (int i = 0; i < rcount; i++)
                    {
                        SOReader sor = model.RList[i] as SOReader;
                        rSC.Add(sor);
                    }
                }

                SaleOrderItemDAL item = new SaleOrderItemDAL();
                item.Save(model.SaleOrderID, model.OldSaleOrderID);

                transaction.Commit();
            }
            catch
            {
                transaction.Rollback();
            }

            return(1);
        }
Beispiel #4
0
        /// <summary>
        /// 修改销售订单
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool UpdateSaleOrder(SaleOrder model)
        {
            StringBuilder strSql = new StringBuilder();;

            strSql.Append("update SaleOrder set ");
            strSql.Append("BillTypeID=@BillTypeID,");
            strSql.Append("MaterialID=@MaterialID,");
            strSql.Append("SaleUnitID=@SaleUnitID,");
            strSql.Append("ClientID=@ClientID,");
            strSql.Append("SaleDate=@SaleDate,");
            strSql.Append("SaleQty=@SaleQty,");
            strSql.Append("SalePrice=@SalePrice,");
            strSql.Append("SaleCost=@SaleCost,");
            strSql.Append("FinishDate=@FinishDate,");
            strSql.Append("Editor=@Editor,");
            strSql.Append("EditTime=@EditTime,");
            strSql.Append("FirstChecker=@FirstChecker,");
            strSql.Append("RoutingID=@RoutingID,");
            strSql.Append("Remark=@Remark,");
            strSql.Append("SecondCheckerName=@SecondCheckerName,");
            strSql.Append("ReaderName=@ReaderName,");
            strSql.Append("Routing=@Routing");
            strSql.Append(" where SaleOrderID=@SaleOrderID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@BillTypeID",        SqlDbType.VarChar,     36),
                new SqlParameter("@MaterialID",        SqlDbType.VarChar,     36),
                new SqlParameter("@SaleUnitID",        SqlDbType.VarChar,     36),
                new SqlParameter("@ClientID",          SqlDbType.VarChar,     36),
                new SqlParameter("@SaleDate",          SqlDbType.Char,         8),
                new SqlParameter("@SaleQty",           SqlDbType.Decimal,     13),
                new SqlParameter("@SalePrice",         SqlDbType.Decimal,     13),
                new SqlParameter("@SaleCost",          SqlDbType.Decimal,     13),
                new SqlParameter("@FinishDate",        SqlDbType.Char,         8),
                new SqlParameter("@Editor",            SqlDbType.VarChar,     36),
                new SqlParameter("@EditTime",          SqlDbType.DateTime),
                new SqlParameter("@FirstChecker",      SqlDbType.VarChar,     36),
                new SqlParameter("@RoutingID",         SqlDbType.VarChar,     36),
                new SqlParameter("@Remark",            SqlDbType.VarChar,   1024),
                new SqlParameter("@SecondCheckerName", SqlDbType.VarChar,    255),
                new SqlParameter("@ReaderName",        SqlDbType.VarChar,    255),
                new SqlParameter("@Routing",           SqlDbType.VarChar,   1024),
                new SqlParameter("@SaleOrderID",       SqlDbType.VarChar, 36)
            };
            parameters[0].Value  = model.BillTypeID;
            parameters[1].Value  = model.MaterialID;
            parameters[2].Value  = model.SaleUnitID;
            parameters[3].Value  = model.ClientID;
            parameters[4].Value  = model.SaleDate;
            parameters[5].Value  = model.SaleQty;
            parameters[6].Value  = model.SalePrice;
            parameters[7].Value  = model.SaleCost;
            parameters[8].Value  = model.FinishDate;
            parameters[9].Value  = model.Editor;
            parameters[10].Value = model.EditTime;
            parameters[11].Value = model.FirstChecker;
            parameters[12].Value = model.RoutingID;
            parameters[13].Value = model.Remark;
            parameters[14].Value = model.SecondCheckerName;
            parameters[15].Value = model.ReaderName;
            parameters[16].Value = model.Routing;
            parameters[17].Value = model.SaleOrderID;

            IDbTransaction transaction = DBAccess.BeginDbTransaction(DB.Type, DB.ConnectionString);

            try
            {
                DBAccess.ExecuteNonQuery(DB.Type, DB.ConnectionString, CommandType.Text, strSql.ToString(), parameters);

                SOSecondCheckDAL soSC = new SOSecondCheckDAL();
                int socount           = model.SOList.Count;
                if (socount > 0)
                {
                    soSC.Delete(model.SaleOrderID);
                    for (int i = 0; i < socount; i++)
                    {
                        SOSecondCheck sosc = model.SOList[i] as SOSecondCheck;
                        soSC.Add(sosc);
                    }
                }

                SOReaderDAL rSC    = new SOReaderDAL();
                int         rcount = model.RList.Count;
                if (rcount > 0)
                {
                    rSC.Delete(model.SaleOrderID);
                    for (int i = 0; i < rcount; i++)
                    {
                        SOReader sor = model.RList[i] as SOReader;
                        rSC.Add(sor);
                    }
                }

                transaction.Commit();
            }
            catch
            {
                transaction.Rollback();
            }

            return(true);
        }