예제 #1
0
파일: StoreInOrder.cs 프로젝트: uwitec/MWMS
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DTcms.Model.StoreInOrder model)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("update StoreInOrder set ");

                        strSql.Append(" CustomerId = @CustomerId , ");
                        strSql.Append(" BeginChargingTime = @BeginChargingTime , ");
                        strSql.Append(" ChargingTime = @ChargingTime , ");
                        strSql.Append(" Admin = @Admin , ");
                        strSql.Append(" ChargingCount = @ChargingCount , ");
                        strSql.Append(" InspectionNumber = @InspectionNumber , ");
                        strSql.Append(" AccountNumber = @AccountNumber , ");
                        strSql.Append(" SuttleWeight = @SuttleWeight , ");
                        strSql.Append(" Remark = @Remark  ");
                        strSql.Append(" where Id=@Id ");

                        SqlParameter[] parameters = {
                                    new SqlParameter("@Id", SqlDbType.Int,4) ,
                                    new SqlParameter("@CustomerId", SqlDbType.Int,4) ,
                                    new SqlParameter("@BeginChargingTime", SqlDbType.DateTime) ,
                                    new SqlParameter("@ChargingTime", SqlDbType.DateTime) ,
                                    new SqlParameter("@Admin", SqlDbType.VarChar,254) ,
                                    new SqlParameter("@ChargingCount", SqlDbType.Decimal,9) ,
                                    new SqlParameter("@InspectionNumber", SqlDbType.VarChar,254) ,
                                    new SqlParameter("@AccountNumber", SqlDbType.VarChar,254) ,
                                    new SqlParameter("@SuttleWeight", SqlDbType.Decimal,9) ,
                                    new SqlParameter("@Remark", SqlDbType.VarChar,254)

                        };

                        parameters[0].Value = model.Id;
                        parameters[1].Value = model.CustomerId;
                        parameters[2].Value = model.BeginChargingTime;
                        parameters[3].Value = model.ChargingTime;
                        parameters[4].Value = model.Admin;
                        parameters[5].Value = model.ChargingCount;
                        parameters[6].Value = model.InspectionNumber;
                        parameters[7].Value = model.AccountNumber;
                        parameters[8].Value = model.SuttleWeight;
                        parameters[9].Value = model.Remark;

                        DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), parameters);

                        #region 单价
                        StoreInUnitPrice unitPriceDAL = new StoreInUnitPrice();
                        unitPriceDAL.Delete(conn, trans, model.Id);
                        if (model.UnitPrices.Count > 0)
                        {
                            foreach (Model.StoreInUnitPrice unitPrice in model.UnitPrices)
                            {
                                unitPrice.StoreInOrderId = model.Id;
                                unitPriceDAL.Add(conn, trans, unitPrice);
                            }
                        }
                        #endregion

                        #region 费用
                        StoreInCost costDAL = new StoreInCost();
                        costDAL.Delete(conn, trans, model.Id);
                        if (model.StoreInCosts.Count > 0)
                        {
                            foreach (Model.StoreInCost cost in model.StoreInCosts)
                            {
                                cost.StoreInOrderId = model.Id;
                                costDAL.Add(conn, trans, cost);
                            }
                        }
                        #endregion

                        #region 入库货物====================
                        StoreInGoods storeInGoodsDAL = new StoreInGoods();
                        storeInGoodsDAL.Delete(conn, trans, model.Id);
                        if (model.StoreInGoods.Count > 0)
                        {
                            StoreWaitingGoods waitingGoodsDAL = new StoreWaitingGoods();
                            foreach (Model.StoreInGoods storeInGoods in model.StoreInGoods)
                            {
                                storeInGoods.StoreInOrderId = model.Id;
                                storeInGoodsDAL.Add(conn, trans, storeInGoods);
                                waitingGoodsDAL.UpdateStatus(conn, trans, storeInGoods.StoreWaitingGoodsId, 1);
                            }
                        }
                        #endregion

                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        return false;
                    }
                }
            }

            return true;
        }
예제 #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(DTcms.Model.StoreInOrder model)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("insert into StoreInOrder(");
                        strSql.Append("CustomerId,Status,CreateTime,BeginChargingTime,ChargingTime,Admin,ChargingCount,InspectionNumber,AccountNumber,SuttleWeight,Remark");
                        strSql.Append(") values (");
                        strSql.Append("@CustomerId,@Status,@CreateTime,@BeginChargingTime,@ChargingTime,@Admin,@ChargingCount,@InspectionNumber,@AccountNumber,@SuttleWeight,@Remark");
                        strSql.Append(") ");
                        strSql.Append(";select @@IDENTITY");
                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@CustomerId",        SqlDbType.Int,         4),
                            new SqlParameter("@Status",            SqlDbType.Int,         4),
                            new SqlParameter("@CreateTime",        SqlDbType.DateTime),
                            new SqlParameter("@BeginChargingTime", SqlDbType.DateTime),
                            new SqlParameter("@ChargingTime",      SqlDbType.DateTime),
                            new SqlParameter("@Admin",             SqlDbType.VarChar,   254),
                            new SqlParameter("@ChargingCount",     SqlDbType.Decimal,     9),
                            new SqlParameter("@InspectionNumber",  SqlDbType.VarChar,   254),
                            new SqlParameter("@AccountNumber",     SqlDbType.VarChar,   254),
                            new SqlParameter("@SuttleWeight",      SqlDbType.Decimal,     9),
                            new SqlParameter("@Remark",            SqlDbType.VarChar, 254)
                        };

                        parameters[0].Value  = model.CustomerId;
                        parameters[1].Value  = model.Status;
                        parameters[2].Value  = model.CreateTime;
                        parameters[3].Value  = model.BeginChargingTime;
                        parameters[4].Value  = model.ChargingTime;
                        parameters[5].Value  = model.Admin;
                        parameters[6].Value  = model.ChargingCount;
                        parameters[7].Value  = model.InspectionNumber;
                        parameters[8].Value  = model.AccountNumber;
                        parameters[9].Value  = model.SuttleWeight;
                        parameters[10].Value = model.Remark;

                        object obj = DbHelperSQL.GetSingle(conn, trans, strSql.ToString(), parameters); //带事务
                        model.Id = Convert.ToInt32(obj);

                        #region 单价====================
                        if (model.UnitPrices.Count > 0)
                        {
                            StoreInUnitPrice unitPriceDAL = new StoreInUnitPrice();
                            foreach (Model.StoreInUnitPrice unitPrice in model.UnitPrices)
                            {
                                unitPrice.StoreInOrderId = model.Id;
                                unitPriceDAL.Add(conn, trans, unitPrice);
                            }
                        }
                        #endregion

                        #region 费用====================
                        if (model.StoreInCosts.Count > 0)
                        {
                            StoreInCost storeInCostDAL = new StoreInCost();
                            foreach (Model.StoreInCost storeInCost in model.StoreInCosts)
                            {
                                storeInCost.StoreInOrderId = model.Id;
                                storeInCostDAL.Add(conn, trans, storeInCost);
                            }
                        }
                        #endregion

                        #region 入库货物====================
                        if (model.StoreInGoods.Count > 0)
                        {
                            StoreInGoods      storeInGoodsDAL = new StoreInGoods();
                            StoreWaitingGoods waitingGoodsDAL = new StoreWaitingGoods();
                            foreach (Model.StoreInGoods storeInGoods in model.StoreInGoods)
                            {
                                storeInGoods.StoreInOrderId = model.Id;
                                storeInGoodsDAL.Add(conn, trans, storeInGoods);
                                waitingGoodsDAL.UpdateStatus(conn, trans, storeInGoods.StoreWaitingGoodsId, 1);
                            }
                        }
                        #endregion

                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        return(false);
                    }
                }
            }

            return(model.Id > 0);
        }
예제 #3
0
파일: StoreInOrder.cs 프로젝트: uwitec/MWMS
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(DTcms.Model.StoreInOrder model)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("insert into StoreInOrder(");
                        strSql.Append("CustomerId,Status,CreateTime,BeginChargingTime,ChargingTime,Admin,ChargingCount,InspectionNumber,AccountNumber,SuttleWeight,Remark");
                        strSql.Append(") values (");
                        strSql.Append("@CustomerId,@Status,@CreateTime,@BeginChargingTime,@ChargingTime,@Admin,@ChargingCount,@InspectionNumber,@AccountNumber,@SuttleWeight,@Remark");
                        strSql.Append(") ");
                        strSql.Append(";select @@IDENTITY");
                        SqlParameter[] parameters = {
                                    new SqlParameter("@CustomerId", SqlDbType.Int,4) ,
                                    new SqlParameter("@Status", SqlDbType.Int,4) ,
                                    new SqlParameter("@CreateTime", SqlDbType.DateTime) ,
                                    new SqlParameter("@BeginChargingTime", SqlDbType.DateTime) ,
                                    new SqlParameter("@ChargingTime", SqlDbType.DateTime) ,
                                    new SqlParameter("@Admin", SqlDbType.VarChar,254) ,
                                    new SqlParameter("@ChargingCount", SqlDbType.Decimal,9) ,
                                    new SqlParameter("@InspectionNumber", SqlDbType.VarChar,254) ,
                                    new SqlParameter("@AccountNumber", SqlDbType.VarChar,254) ,
                                    new SqlParameter("@SuttleWeight", SqlDbType.Decimal,9) ,
                                    new SqlParameter("@Remark", SqlDbType.VarChar,254)

                        };

                        parameters[0].Value = model.CustomerId;
                        parameters[1].Value = model.Status;
                        parameters[2].Value = model.CreateTime;
                        parameters[3].Value = model.BeginChargingTime;
                        parameters[4].Value = model.ChargingTime;
                        parameters[5].Value = model.Admin;
                        parameters[6].Value = model.ChargingCount;
                        parameters[7].Value = model.InspectionNumber;
                        parameters[8].Value = model.AccountNumber;
                        parameters[9].Value = model.SuttleWeight;
                        parameters[10].Value = model.Remark;

                        object obj = DbHelperSQL.GetSingle(conn, trans, strSql.ToString(), parameters); //带事务
                        model.Id = Convert.ToInt32(obj);

                        #region 单价====================
                        if (model.UnitPrices.Count > 0)
                        {
                            StoreInUnitPrice unitPriceDAL = new StoreInUnitPrice();
                            foreach (Model.StoreInUnitPrice unitPrice in model.UnitPrices)
                            {
                                unitPrice.StoreInOrderId = model.Id;
                                unitPriceDAL.Add(conn, trans, unitPrice);
                            }
                        }
                        #endregion

                        #region 费用====================
                        if (model.StoreInCosts.Count > 0)
                        {
                            StoreInCost storeInCostDAL = new StoreInCost();
                            foreach (Model.StoreInCost storeInCost in model.StoreInCosts)
                            {
                                storeInCost.StoreInOrderId = model.Id;
                                storeInCostDAL.Add(conn, trans, storeInCost);
                            }
                        }
                        #endregion

                        #region 入库货物====================
                        if (model.StoreInGoods.Count > 0)
                        {
                            StoreInGoods storeInGoodsDAL = new StoreInGoods();
                            StoreWaitingGoods waitingGoodsDAL = new StoreWaitingGoods();
                            foreach (Model.StoreInGoods storeInGoods in model.StoreInGoods)
                            {
                                storeInGoods.StoreInOrderId = model.Id;
                                storeInGoodsDAL.Add(conn, trans, storeInGoods);
                                waitingGoodsDAL.UpdateStatus(conn, trans, storeInGoods.StoreWaitingGoodsId, 1);
                            }
                        }
                        #endregion

                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        return false;
                    }
                }
            }

            return model.Id > 0;
        }
예제 #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DTcms.Model.StoreInOrder model)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("update StoreInOrder set ");

                        strSql.Append(" CustomerId = @CustomerId , ");
                        strSql.Append(" BeginChargingTime = @BeginChargingTime , ");
                        strSql.Append(" ChargingTime = @ChargingTime , ");
                        strSql.Append(" Admin = @Admin , ");
                        strSql.Append(" ChargingCount = @ChargingCount , ");
                        strSql.Append(" InspectionNumber = @InspectionNumber , ");
                        strSql.Append(" AccountNumber = @AccountNumber , ");
                        strSql.Append(" SuttleWeight = @SuttleWeight , ");
                        strSql.Append(" Remark = @Remark  ");
                        strSql.Append(" where Id=@Id ");

                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@Id",                SqlDbType.Int,         4),
                            new SqlParameter("@CustomerId",        SqlDbType.Int,         4),
                            new SqlParameter("@BeginChargingTime", SqlDbType.DateTime),
                            new SqlParameter("@ChargingTime",      SqlDbType.DateTime),
                            new SqlParameter("@Admin",             SqlDbType.VarChar,   254),
                            new SqlParameter("@ChargingCount",     SqlDbType.Decimal,     9),
                            new SqlParameter("@InspectionNumber",  SqlDbType.VarChar,   254),
                            new SqlParameter("@AccountNumber",     SqlDbType.VarChar,   254),
                            new SqlParameter("@SuttleWeight",      SqlDbType.Decimal,     9),
                            new SqlParameter("@Remark",            SqlDbType.VarChar, 254)
                        };

                        parameters[0].Value = model.Id;
                        parameters[1].Value = model.CustomerId;
                        parameters[2].Value = model.BeginChargingTime;
                        parameters[3].Value = model.ChargingTime;
                        parameters[4].Value = model.Admin;
                        parameters[5].Value = model.ChargingCount;
                        parameters[6].Value = model.InspectionNumber;
                        parameters[7].Value = model.AccountNumber;
                        parameters[8].Value = model.SuttleWeight;
                        parameters[9].Value = model.Remark;

                        DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), parameters);

                        #region 单价
                        StoreInUnitPrice unitPriceDAL = new StoreInUnitPrice();
                        unitPriceDAL.Delete(conn, trans, model.Id);
                        if (model.UnitPrices.Count > 0)
                        {
                            foreach (Model.StoreInUnitPrice unitPrice in model.UnitPrices)
                            {
                                unitPrice.StoreInOrderId = model.Id;
                                unitPriceDAL.Add(conn, trans, unitPrice);
                            }
                        }
                        #endregion

                        #region 费用
                        StoreInCost costDAL = new StoreInCost();
                        costDAL.Delete(conn, trans, model.Id);
                        if (model.StoreInCosts.Count > 0)
                        {
                            foreach (Model.StoreInCost cost in model.StoreInCosts)
                            {
                                cost.StoreInOrderId = model.Id;
                                costDAL.Add(conn, trans, cost);
                            }
                        }
                        #endregion

                        #region 入库货物====================
                        StoreInGoods storeInGoodsDAL = new StoreInGoods();
                        storeInGoodsDAL.Delete(conn, trans, model.Id);
                        if (model.StoreInGoods.Count > 0)
                        {
                            StoreWaitingGoods waitingGoodsDAL = new StoreWaitingGoods();
                            foreach (Model.StoreInGoods storeInGoods in model.StoreInGoods)
                            {
                                storeInGoods.StoreInOrderId = model.Id;
                                storeInGoodsDAL.Add(conn, trans, storeInGoods);
                                waitingGoodsDAL.UpdateStatus(conn, trans, storeInGoods.StoreWaitingGoodsId, 1);
                            }
                        }
                        #endregion


                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        return(false);
                    }
                }
            }

            return(true);
        }