예제 #1
0
        public static int SaveAimCheckInfo(AimCheckInfoModel model)
        {
            //定义返回变量
            int isSucc = 0;

            //ID存在时,更新
            if (ConstUtil.EDIT_FLAG_UPDATE.Equals(model.EditFlag))
            {
                try
                {
                    //执行更新操作
                    isSucc = AimCheckInfoDBHelper.UpdateAimCheckInfo(model);
                }
                catch
                {
                    //输出日志

                }
            }
            //插入
            else
            {
                try
                {
                    //执行插入操作
                    isSucc = AimCheckInfoDBHelper.InsertAimCheckInfo(model);
                }
                catch
                {
                    //输出日志

                }
            }
            return isSucc;
        }
        /// <summary>
        /// 得到一个 检查的结果
        /// </summary>
        public static DataTable GetAimCheckRecord(int ID)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select   p.Checkor,AimNo,AimTitle ,p.id as Cid ,officedba.getEmployeeNameByID(p.Checkor) as CheckorName,CheckContent , AimID,AimTypeID,AimDate,AimStandard,Status,p.CheckMethod , p.CheckDate,p.CheckResult,p.AddOrCut,p.Remark from  ");
            strSql.Append("  officedba.PlanAim o join  officedba.PlanCheck p on o.ID = p.AimID  ");
            strSql.Append(" where p.ID=@ID ");
            SqlParameter[] parameters = {
					new SqlParameter("@ID", SqlDbType.Int,4)};
            parameters[0].Value = ID;

            AimCheckInfoModel model = new AimCheckInfoModel();

            SqlCommand comm = new SqlCommand();
            comm.Parameters.Add(parameters[0]);
            comm.CommandText = strSql.ToString();
            return SqlHelper.ExecuteSearch(comm);
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static int UpdateAimCheckInfo(AimCheckInfoModel model)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("update officedba.PlanCheck set ");
            strSql.Append("CheckDate=@CheckDate,");
            strSql.Append("Checkor=@Checkor,");
            strSql.Append("CheckMethod=@CheckMethod,");
            strSql.Append("CheckContent=@CheckContent,");
            strSql.Append("CheckResult=@CheckResult,");
            strSql.Append("remark=@remark,");
            strSql.Append("ModifiedDate=@ModifiedDate,");
            strSql.Append("ModifiedUserID=@ModifiedUserID,");
            strSql.Append("AddOrCut=@AddOrCut");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters = {
					new SqlParameter("@ID", SqlDbType.Int,4),
					new SqlParameter("@CheckDate", SqlDbType.DateTime),
					new SqlParameter("@Checkor", SqlDbType.Int,4),
					new SqlParameter("@CheckMethod", SqlDbType.VarChar,50),
					new SqlParameter("@CheckContent", SqlDbType.VarChar,1024),
					new SqlParameter("@CheckResult", SqlDbType.VarChar,1024),
					new SqlParameter("@remark", SqlDbType.VarChar,1024),
					new SqlParameter("@ModifiedDate", SqlDbType.DateTime),
					new SqlParameter("@ModifiedUserID", SqlDbType.VarChar,10),
					new SqlParameter("@AddOrCut", SqlDbType.Char,1)};
            parameters[0].Value = model.ID;
            parameters[1].Value = model.CheckDate;
            parameters[2].Value = model.Checkor;
            parameters[3].Value = model.CheckMethod;
            parameters[4].Value = model.CheckContent;
            parameters[5].Value = model.CheckResult;
            parameters[6].Value = model.remark;
            parameters[7].Value = model.ModifiedDate;
            parameters[8].Value = model.ModifiedUserID;
            parameters[9].Value = model.AddOrCut;

            return SqlHelper.ExecuteTransSql(strSql.ToString(), parameters);

        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static int InsertAimCheckInfo(AimCheckInfoModel model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into officedba.PlanCheck(");
            strSql.Append("CompanyCD,AimID,CheckDate,Checkor,CheckMethod,CheckContent,CheckResult,remark,ModifiedUserID,AddOrCut)");
            strSql.Append(" values (");
            strSql.Append("@CompanyCD,@AimID,@CheckDate,@Checkor,@CheckMethod,@CheckContent,@CheckResult,@remark,@ModifiedUserID,@AddOrCut)");
            strSql.Append(";select @ID =@@IDENTITY");
            SqlParameter[] parameters = {
					new SqlParameter("@CompanyCD", SqlDbType.VarChar,8),
					new SqlParameter("@AimID", SqlDbType.Int,4),
					new SqlParameter("@CheckDate", SqlDbType.DateTime),
					new SqlParameter("@Checkor", SqlDbType.Int,4),
					new SqlParameter("@CheckMethod", SqlDbType.VarChar,50),
					new SqlParameter("@CheckContent", SqlDbType.VarChar,1024),
					new SqlParameter("@CheckResult", SqlDbType.VarChar,1024),
					new SqlParameter("@remark", SqlDbType.VarChar,1024),
					new SqlParameter("@ModifiedUserID", SqlDbType.VarChar,10),
					new SqlParameter("@AddOrCut", SqlDbType.Char,1),
                    new SqlParameter("@ID", SqlDbType.Int,0) };
            parameters[0].Value = model.CompanyCD;
            parameters[1].Value = model.AimID;
            parameters[2].Value = model.CheckDate;
            parameters[3].Value = model.Checkor;
            parameters[4].Value = model.CheckMethod;
            parameters[5].Value = model.CheckContent;
            parameters[6].Value = model.CheckResult;
            parameters[7].Value = model.remark;
            parameters[8].Value = model.ModifiedUserID;
            parameters[9].Value = model.AddOrCut;
            parameters[10].Direction = ParameterDirection.Output;

            SqlHelper.ExecuteTransSql(strSql.ToString(), parameters);
            return Convert.ToInt32((parameters[10].Value.ToString()));

        }