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="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);
        }