コード例 #1
0
ファイル: AllotOrder.cs プロジェクト: xuxingliu922/MWMS
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DTcms.Model.AllotOrder model)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("update AllotOrder set ");
                        strSql.Append(" Remark = @Remark , ");
                        strSql.Append(" AllotTime = @AllotTime , ");
                        strSql.Append(" Admin = @Admin  ");
                        strSql.Append(" where Id=@Id ");

                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@Id",        SqlDbType.Int,         4),
                            new SqlParameter("@Remark",    SqlDbType.VarChar,   254),
                            new SqlParameter("@AllotTime", SqlDbType.DateTime),
                            new SqlParameter("@Admin",     SqlDbType.VarChar, 254)
                        };

                        parameters[0].Value = model.Id;
                        parameters[1].Value = model.Remark;
                        parameters[2].Value = model.AllotTime;
                        parameters[3].Value = model.Admin;

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


                        #region 调拨货物====================
                        AllotGoods allotGoodsDAL = new AllotGoods();

                        allotGoodsDAL.Delete(conn, trans, model.Id);

                        if (model.AllotGoods.Count > 0)
                        {
                            foreach (Model.AllotGoods allotGoods in model.AllotGoods)
                            {
                                allotGoods.AllotOrderId = model.Id;
                                allotGoodsDAL.Add(conn, trans, allotGoods);
                            }
                        }
                        #endregion


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

            return(true);
        }
コード例 #2
0
ファイル: AllotOrder.cs プロジェクト: xuxingliu922/MWMS
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(DTcms.Model.AllotOrder model)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("insert into AllotOrder(");
                        strSql.Append("AllotTime,Status,Remark,CreateTime,Admin");
                        strSql.Append(") values (");
                        strSql.Append("@AllotTime,@Status,@Remark,@CreateTime,@Admin");
                        strSql.Append(") ");
                        strSql.Append(";select @@IDENTITY");
                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@AllotTime",  SqlDbType.DateTime),
                            new SqlParameter("@Status",     SqlDbType.Int,         4),
                            new SqlParameter("@Remark",     SqlDbType.VarChar,   254),
                            new SqlParameter("@CreateTime", SqlDbType.DateTime),
                            new SqlParameter("@Admin",      SqlDbType.VarChar, 254)
                        };

                        parameters[0].Value = model.AllotTime;
                        parameters[1].Value = model.Status;
                        parameters[2].Value = model.Remark;
                        parameters[3].Value = model.CreateTime;
                        parameters[4].Value = model.Admin;

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


                        #region 调拨货物====================
                        if (model.AllotGoods.Count > 0)
                        {
                            AllotGoods allotGoodsDAL = new AllotGoods();
                            foreach (Model.AllotGoods allotGoods in model.AllotGoods)
                            {
                                allotGoods.AllotOrderId = model.Id;
                                allotGoodsDAL.Add(conn, trans, allotGoods);
                            }
                        }
                        #endregion

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

            return(model.Id > 0);
        }
コード例 #3
0
ファイル: AllotOrder.cs プロジェクト: uwitec/MWMS
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(DTcms.Model.AllotOrder model)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("insert into AllotOrder(");
                        strSql.Append("AllotTime,Status,Remark,CreateTime,Admin");
                        strSql.Append(") values (");
                        strSql.Append("@AllotTime,@Status,@Remark,@CreateTime,@Admin");
                        strSql.Append(") ");
                        strSql.Append(";select @@IDENTITY");
                        SqlParameter[] parameters = {
                                    new SqlParameter("@AllotTime", SqlDbType.DateTime) ,
                                    new SqlParameter("@Status", SqlDbType.Int,4) ,
                                    new SqlParameter("@Remark", SqlDbType.VarChar,254) ,
                                    new SqlParameter("@CreateTime", SqlDbType.DateTime) ,
                                    new SqlParameter("@Admin", SqlDbType.VarChar,254)
                        };

                        parameters[0].Value = model.AllotTime;
                        parameters[1].Value = model.Status;
                        parameters[2].Value = model.Remark;
                        parameters[3].Value = model.CreateTime;
                        parameters[4].Value = model.Admin;

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

                        #region 调拨货物====================
                        if (model.AllotGoods.Count > 0)
                        {
                            AllotGoods allotGoodsDAL = new AllotGoods();
                            foreach (Model.AllotGoods allotGoods in model.AllotGoods)
                            {
                                allotGoods.AllotOrderId = model.Id;
                                allotGoodsDAL.Add(conn, trans, allotGoods);
                            }
                        }
                        #endregion

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

            return model.Id > 0;
        }
コード例 #4
0
ファイル: AllotOrder.cs プロジェクト: uwitec/MWMS
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DTcms.Model.AllotOrder model)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("update AllotOrder set ");
                        strSql.Append(" Remark = @Remark , ");
                        strSql.Append(" AllotTime = @AllotTime , ");
                        strSql.Append(" Admin = @Admin  ");
                        strSql.Append(" where Id=@Id ");

                        SqlParameter[] parameters = {
                                    new SqlParameter("@Id", SqlDbType.Int,4) ,
                                    new SqlParameter("@Remark", SqlDbType.VarChar,254) ,
                                    new SqlParameter("@AllotTime", SqlDbType.DateTime) ,
                                    new SqlParameter("@Admin", SqlDbType.VarChar,254)

                        };

                        parameters[0].Value = model.Id;
                        parameters[1].Value = model.Remark;
                        parameters[2].Value = model.AllotTime;
                        parameters[3].Value = model.Admin;

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

                        #region 调拨货物====================
                        AllotGoods allotGoodsDAL = new AllotGoods();

                        allotGoodsDAL.Delete(conn, trans, model.Id);

                        if (model.AllotGoods.Count > 0)
                        {
                            foreach (Model.AllotGoods allotGoods in model.AllotGoods)
                            {
                                allotGoods.AllotOrderId = model.Id;
                                allotGoodsDAL.Add(conn, trans, allotGoods);
                            }
                        }
                        #endregion

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

            return true;
        }