예제 #1
0
파일: CheckRecord.cs 프로젝트: uwitec/MWMS
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DTcms.Model.CheckRecord model)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("update CheckRecord set ");
                        strSql.Append(" VehicleId = @VehicleId , ");
                        strSql.Append(" CustomerId = @CustomerId , ");
                        strSql.Append(" HandlingModeId = @HandlingModeId , ");
                        strSql.Append(" GoodsId = @GoodsId , ");
                        strSql.Append(" Status = @Status , ");
                        strSql.Append(" CreateTime = @CreateTime , ");
                        strSql.Append(" Admin = @Admin , ");
                        strSql.Append(" InspectionNumber = @InspectionNumber , ");
                        strSql.Append(" CaseNumber = @CaseNumber , ");
                        strSql.Append(" CheckResult = @CheckResult , ");
                        strSql.Append(" RealName = @RealName , ");
                        strSql.Append(" LinkTel = @LinkTel , ");
                        strSql.Append(" Remark = @Remark,  ");
                        strSql.Append(" CheckTime = @CheckTime  ");
                        strSql.Append(" where Id=@Id ");

                        SqlParameter[] parameters = {
                                    new SqlParameter("@Id", SqlDbType.Int,4) ,
                                    new SqlParameter("@VehicleId", SqlDbType.Int,4) ,
                                    new SqlParameter("@CustomerId", SqlDbType.Int,4) ,
                                    new SqlParameter("@HandlingModeId", SqlDbType.Int,4) ,
                                    new SqlParameter("@GoodsId", SqlDbType.Int,4) ,
                                    new SqlParameter("@Status", SqlDbType.Int,4) ,
                                    new SqlParameter("@CreateTime", SqlDbType.DateTime) ,
                                    new SqlParameter("@Admin", SqlDbType.VarChar,254) ,
                                    new SqlParameter("@InspectionNumber", SqlDbType.VarChar,254) ,
                                    new SqlParameter("@CaseNumber", SqlDbType.VarChar,254) ,
                                    new SqlParameter("@CheckResult", SqlDbType.VarChar,254) ,
                                    new SqlParameter("@RealName", SqlDbType.VarChar,254) ,
                                    new SqlParameter("@LinkTel", SqlDbType.VarChar,254) ,
                                    new SqlParameter("@Remark", SqlDbType.VarChar,254)  ,
                                    new SqlParameter("@CheckTime", SqlDbType.DateTime)

                        };

                        parameters[0].Value = model.Id;
                        parameters[1].Value = model.VehicleId;
                        parameters[2].Value = model.CustomerId;
                        parameters[3].Value = model.HandlingModeId;
                        parameters[4].Value = model.GoodsId;
                        parameters[5].Value = model.Status;
                        parameters[6].Value = model.CreateTime;
                        parameters[7].Value = model.Admin;
                        parameters[8].Value = model.InspectionNumber;
                        parameters[9].Value = model.CaseNumber;
                        parameters[10].Value = model.CheckResult;
                        parameters[11].Value = model.RealName;
                        parameters[12].Value = model.LinkTel;
                        parameters[13].Value = model.Remark;
                        parameters[14].Value = model.CheckTime;

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

                        #region 费用
                        CheckCost checkCostDAL = new CheckCost();
                        checkCostDAL.Delete(conn, trans, model.Id);
                        if (model.CheckCosts.Count > 0)
                        {
                            foreach (Model.CheckCost checkCost in model.CheckCosts)
                            {
                                checkCost.CheckRecordId = model.Id;
                                checkCostDAL.Add(conn, trans, checkCost);
                            }
                        }
                        #endregion

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

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

                        parameters[0].Value  = model.VehicleId;
                        parameters[1].Value  = model.CustomerId;
                        parameters[2].Value  = model.HandlingModeId;
                        parameters[3].Value  = model.GoodsId;
                        parameters[4].Value  = model.Status;
                        parameters[5].Value  = model.CreateTime;
                        parameters[6].Value  = model.Admin;
                        parameters[7].Value  = model.InspectionNumber;
                        parameters[8].Value  = model.CaseNumber;
                        parameters[9].Value  = model.CheckResult;
                        parameters[10].Value = model.RealName;
                        parameters[11].Value = model.LinkTel;
                        parameters[12].Value = model.Remark;
                        parameters[13].Value = model.CheckTime;

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

                        #region 费用====================
                        if (model.CheckCosts.Count > 0)
                        {
                            CheckCost checkCostDAL = new CheckCost();
                            foreach (Model.CheckCost checkCost in model.CheckCosts)
                            {
                                checkCost.CheckRecordId = model.Id;
                                checkCostDAL.Add(conn, trans, checkCost);
                            }
                        }
                        #endregion

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

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

                        };

                        parameters[0].Value = model.VehicleId;
                        parameters[1].Value = model.CustomerId;
                        parameters[2].Value = model.HandlingModeId;
                        parameters[3].Value = model.GoodsId;
                        parameters[4].Value = model.Status;
                        parameters[5].Value = model.CreateTime;
                        parameters[6].Value = model.Admin;
                        parameters[7].Value = model.InspectionNumber;
                        parameters[8].Value = model.CaseNumber;
                        parameters[9].Value = model.CheckResult;
                        parameters[10].Value = model.RealName;
                        parameters[11].Value = model.LinkTel;
                        parameters[12].Value = model.Remark;
                        parameters[13].Value = model.CheckTime;

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

                        #region 费用====================
                        if (model.CheckCosts.Count > 0)
                        {
                            CheckCost checkCostDAL = new CheckCost();
                            foreach (Model.CheckCost checkCost in model.CheckCosts)
                            {
                                checkCost.CheckRecordId = model.Id;
                                checkCostDAL.Add(conn, trans, checkCost);
                            }
                        }
                        #endregion

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

            return model.Id > 0;
        }
예제 #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DTcms.Model.CheckRecord model)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("update CheckRecord set ");
                        strSql.Append(" VehicleId = @VehicleId , ");
                        strSql.Append(" CustomerId = @CustomerId , ");
                        strSql.Append(" HandlingModeId = @HandlingModeId , ");
                        strSql.Append(" GoodsId = @GoodsId , ");
                        strSql.Append(" Status = @Status , ");
                        strSql.Append(" CreateTime = @CreateTime , ");
                        strSql.Append(" Admin = @Admin , ");
                        strSql.Append(" InspectionNumber = @InspectionNumber , ");
                        strSql.Append(" CaseNumber = @CaseNumber , ");
                        strSql.Append(" CheckResult = @CheckResult , ");
                        strSql.Append(" RealName = @RealName , ");
                        strSql.Append(" LinkTel = @LinkTel , ");
                        strSql.Append(" Remark = @Remark,  ");
                        strSql.Append(" CheckTime = @CheckTime  ");
                        strSql.Append(" where Id=@Id ");

                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@Id",               SqlDbType.Int,         4),
                            new SqlParameter("@VehicleId",        SqlDbType.Int,         4),
                            new SqlParameter("@CustomerId",       SqlDbType.Int,         4),
                            new SqlParameter("@HandlingModeId",   SqlDbType.Int,         4),
                            new SqlParameter("@GoodsId",          SqlDbType.Int,         4),
                            new SqlParameter("@Status",           SqlDbType.Int,         4),
                            new SqlParameter("@CreateTime",       SqlDbType.DateTime),
                            new SqlParameter("@Admin",            SqlDbType.VarChar,   254),
                            new SqlParameter("@InspectionNumber", SqlDbType.VarChar,   254),
                            new SqlParameter("@CaseNumber",       SqlDbType.VarChar,   254),
                            new SqlParameter("@CheckResult",      SqlDbType.VarChar,   254),
                            new SqlParameter("@RealName",         SqlDbType.VarChar,   254),
                            new SqlParameter("@LinkTel",          SqlDbType.VarChar,   254),
                            new SqlParameter("@Remark",           SqlDbType.VarChar,   254),
                            new SqlParameter("@CheckTime",        SqlDbType.DateTime)
                        };

                        parameters[0].Value  = model.Id;
                        parameters[1].Value  = model.VehicleId;
                        parameters[2].Value  = model.CustomerId;
                        parameters[3].Value  = model.HandlingModeId;
                        parameters[4].Value  = model.GoodsId;
                        parameters[5].Value  = model.Status;
                        parameters[6].Value  = model.CreateTime;
                        parameters[7].Value  = model.Admin;
                        parameters[8].Value  = model.InspectionNumber;
                        parameters[9].Value  = model.CaseNumber;
                        parameters[10].Value = model.CheckResult;
                        parameters[11].Value = model.RealName;
                        parameters[12].Value = model.LinkTel;
                        parameters[13].Value = model.Remark;
                        parameters[14].Value = model.CheckTime;

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


                        #region 费用
                        CheckCost checkCostDAL = new CheckCost();
                        checkCostDAL.Delete(conn, trans, model.Id);
                        if (model.CheckCosts.Count > 0)
                        {
                            foreach (Model.CheckCost checkCost in model.CheckCosts)
                            {
                                checkCost.CheckRecordId = model.Id;
                                checkCostDAL.Add(conn, trans, checkCost);
                            }
                        }
                        #endregion

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


                return(true);
            }
        }