예제 #1
0
        public bool UpdateModule(ModuleAccess module, AgreementInfoAccess agreement)
        {
            ConnectDB  db = new ConnectDB();
            SqlCommand cmd;

            cmd             = new SqlCommand("UpdateModule");
            cmd.CommandType = CommandType.StoredProcedure;
            SqlParameter RetVal = cmd.Parameters.Add("RetVal", SqlDbType.Int);

            RetVal.Direction = ParameterDirection.ReturnValue;

            //@moduleName VARCHAR(255) ,
            //  @description VARCHAR(255) = NULL,
            //  @expiryDate DATETIME = NULL,
            //  @creationDate DATETIME = null,
            //  @userType VARCHAR(255),
            //  @content VARCHAR(2048) = NULL

            SqlParameter moduleId = cmd.Parameters.Add("@moduleId", SqlDbType.Int);

            moduleId.Direction = ParameterDirection.Input;

            SqlParameter moduleName = cmd.Parameters.Add("@moduleName", SqlDbType.VarChar, 255);

            moduleName.Direction = ParameterDirection.Input;

            SqlParameter description = cmd.Parameters.Add("@description", SqlDbType.VarChar, 255);

            description.Direction = ParameterDirection.Input;

            SqlParameter expiryDate = cmd.Parameters.Add("@expiryDate", SqlDbType.DateTime);

            expiryDate.Direction = ParameterDirection.Input;

            SqlParameter creationDate = cmd.Parameters.Add("@creationDate", SqlDbType.DateTime);

            creationDate.Direction = ParameterDirection.Input;

            SqlParameter userType = cmd.Parameters.Add("@userType", SqlDbType.VarChar, 255);

            userType.Direction = ParameterDirection.Input;

            SqlParameter content = cmd.Parameters.Add("@content", SqlDbType.VarChar, 2048);

            content.Direction = ParameterDirection.Input;

            if (module.ModuleId != 0)
            {
                return(false);
            }
            moduleId.Value = module.ModuleId;
            if (module.ModuleName != null)
            {
                moduleName.Value = module.ModuleName;
            }
            if (module.Description != null)
            {
                description.Value = module.Description;
            }
            if (module.ExpiryDate != null)
            {
                expiryDate.Value = module.ExpiryDate;
            }

            creationDate.Value = DateTime.Now;

            if (agreement.UserType != null)
            {
                userType.Value = agreement.UserType;
            }
            if (agreement.Content != null)
            {
                content.Value = agreement.Content;
            }

            db.changeData(cmd);
            db.Close();

            if (Int32.Parse(RetVal.Value.ToString()) == 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        public AgreementInfoAccess ShowAgreement(int moduleId)
        {
            AgreementInfoAccess agreement = new AgreementInfoAccess();

            ConnectDB     db = new ConnectDB();
            SqlCommand    cmd;
            SqlDataReader dr;

            cmd             = new SqlCommand();
            cmd.CommandType = CommandType.Text;
            if (moduleId == 0)
            {
                return(agreement);
            }
            else
            {
                cmd.CommandText = "SELECT userType, content, moduleId FROM AgreementInformation WHERE moduleId = @moduleId;";
                cmd.Parameters.Add("@moduleId", SqlDbType.Int).Value = moduleId;
            }

            dr = db.searchData(cmd);
            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    if (System.DBNull.Value.Equals(dr[0]))
                    {
                        agreement.UserType = null;
                    }
                    else
                    {
                        agreement.UserType = Convert.ToString(dr[0]);
                    }

                    if (System.DBNull.Value.Equals(dr[1]))
                    {
                        agreement.Content = null;
                    }
                    else
                    {
                        agreement.Content = Convert.ToString(dr[1]);
                    }

                    if (System.DBNull.Value.Equals(dr[2]))
                    {
                        agreement.ModuleId = 0;
                    }
                    else
                    {
                        agreement.ModuleId = Convert.ToInt32(dr[2]);
                    }
                }
            }

            if ((dr != null) && (!dr.IsClosed))
            {
                dr.Close();
            }
            db.Close();
            return(agreement);
        }