Beispiel #1
0
        private AccountRoles_Info GenerateObject(DataRow row)
        {
            AccountRoles_Info objAccountRolesInfo = new AccountRoles_Info();

            if (row == null)
            {
                throw new Exception("DataRow not be empty");
            }
            if (row["ID"] != DBNull.Value)
            {
                objAccountRolesInfo.ID = Convert.ToInt32(row["ID"]);
            }
            if (row["Name"] != DBNull.Value)
            {
                objAccountRolesInfo.Name = Convert.ToString(row["Name"]);
            }
            if (row["Account_ID"] != DBNull.Value)
            {
                objAccountRolesInfo.Account_ID = Convert.ToString(row["Account_ID"]);
            }
            if (row["Type"] != DBNull.Value)
            {
                objAccountRolesInfo.Type = (AccountRoleType)Enum.Parse(typeof(AccountRoleType), row["Type"].ToString());
            }
            if (row["Operator"] != DBNull.Value)
            {
                objAccountRolesInfo.Operator = (OperatorType)Enum.Parse(typeof(OperatorType), row["Operator"].ToString());
            }
            if (row["Value"] != DBNull.Value)
            {
                objAccountRolesInfo.Value = Convert.ToDecimal(row["Value"]);
            }
            if (row["Seq"] != DBNull.Value)
            {
                objAccountRolesInfo.Seq = Convert.ToInt32(row["Seq"]);
            }
            if (row["Active"] != DBNull.Value)
            {
                objAccountRolesInfo.Active = Convert.ToBoolean(row["Active"]);
            }
            if (row["Active_Date"] != DBNull.Value)
            {
                objAccountRolesInfo.Active_Date = Convert.ToDateTime(row["Active_Date"]);
            }
            if (row["CreateDate"] != DBNull.Value)
            {
                objAccountRolesInfo.CreateDate = Convert.ToDateTime(row["CreateDate"]);
            }
            if (row["Last_Update"] != DBNull.Value)
            {
                objAccountRolesInfo.Last_Update = Convert.ToDateTime(row["Last_Update"]);
            }
            if (row["UserCreated"] != DBNull.Value)
            {
                objAccountRolesInfo.UserCreated = Convert.ToString(row["UserCreated"]);
            }
            return(objAccountRolesInfo);
        }
Beispiel #2
0
 public static int Update(AccountRoles_Info obj)
 {
     if (obj != null)
     {
         return(dal_ac_roles.Update(obj));
     }
     else
     {
         throw new Exception(dal_ac_roles.Error_Message);
     }
 }
Beispiel #3
0
        public SqlCommand CreateOne(AccountRoles_Info objAccountRolesInfo)
        {
            SqlCommand command = new SqlCommand("INSERT INTO Account_Roles("
                                                + "Name, "
                                                + "Account_ID, "
                                                + "Type, "
                                                + "Operator, "
                                                + "Value, "
                                                + "Seq, "
                                                + "Active, "
                                                + "Active_Date, "
                                                + "CreateDate, "
                                                + "Last_Update, "
                                                + "UserCreated "
                                                + ")"
                                                + "VALUES ("
                                                + "@Name, "
                                                + "@Account_ID, "
                                                + "@Type, "
                                                + "@Operator, "
                                                + "@Value, "
                                                + "@Seq, "
                                                + "@Active, "
                                                + "@Active_Date, "
                                                + "@CreateDate, "
                                                + "@Last_Update, "
                                                + "@UserCreated "
                                                + ")");

            command.CommandType = CommandType.Text;
            command.Parameters.Clear();
            command.Parameters.Add("@Name", SqlDbType.NVarChar, 150).Value      = objAccountRolesInfo.Name;
            command.Parameters.Add("@Type", SqlDbType.NVarChar, 50).Value       = objAccountRolesInfo.Type;
            command.Parameters.Add("@Account_ID", SqlDbType.NVarChar, 50).Value = objAccountRolesInfo.Account_ID;
            command.Parameters.Add("@Value", SqlDbType.Decimal).Value           = objAccountRolesInfo.Value;
            command.Parameters.Add("@Seq", SqlDbType.Int).Value = objAccountRolesInfo.Seq;
            command.Parameters.Add("@Operator", SqlDbType.NVarChar, 50).Value = objAccountRolesInfo.Operator;
            command.Parameters.Add("@Active", SqlDbType.Bit).Value            = objAccountRolesInfo.Active;
            if (objAccountRolesInfo.Active)
            {
                command.Parameters.Add("@Active_Date", SqlDbType.DateTime).Value = objAccountRolesInfo.Active_Date;
            }
            else
            {
                command.Parameters.Add("@Active_Date", SqlDbType.DateTime).Value = DBNull.Value;
            }
            command.Parameters.Add("@CreateDate", SqlDbType.DateTime).Value      = objAccountRolesInfo.Active_Date;
            command.Parameters.Add("@Last_Update", SqlDbType.DateTime).Value     = objAccountRolesInfo.Active_Date;
            command.Parameters.Add("@UserCreated", SqlDbType.NVarChar, 25).Value = objAccountRolesInfo.Active_Date;
            this.AddCommand(command);
            return(command);
        }
Beispiel #4
0
        private void CreateRole()
        {
            AccountRoles_Info ari = new AccountRoles_Info();

            ari.Name        = doc.SelectSingleNode("//request/name").InnerText;
            ari.Type        = (AccountRoleType)Enum.Parse(typeof(AccountRoleType), doc.SelectSingleNode("//request/type").InnerText);
            ari.Operator    = (OperatorType)Enum.Parse(typeof(OperatorType), doc.SelectSingleNode("//request/operation").InnerText);
            ari.Seq         = int.Parse(doc.SelectSingleNode("//request/seq").InnerText);
            ari.UserCreated = "sa";
            ari.Value       = Decimal.Parse(doc.SelectSingleNode("//request/value").InnerText);
            ari.Last_Update = DateTime.Now;
            ari.Active      = true;
            ari.Active_Date = DateTime.Now;
            ari.Account_ID  = doc.SelectSingleNode("//request/account_id").InnerText;
            ari.CreateDate  = DateTime.Now;
            BaseRole baseRole = new BaseRole();

            baseRole.CreateRole(ari);
        }
Beispiel #5
0
        public SqlCommand EditOne(AccountRoles_Info objAccountRolesInfo)
        {
            SqlCommand command = new SqlCommand("UPDATE Account_Roles SET "
                                                + "Name = @Name, "
                                                + "Account_ID = @Account_ID, "
                                                + "Type = @Type, "
                                                + "Operator = @Operator, "
                                                + "Value = @Value, "
                                                + "Seq = @Seq, "
                                                + "Active = @Active, "
                                                + "Active_Date = @Active_Date, "
                                                + "CreateDate = @CreateDate, "
                                                + "Last_Update = @Last_Update, "
                                                + "UserCreated = @UserCreated "
                                                + "WHERE ID = @ID");

            command.CommandType = CommandType.Text;
            command.Parameters.Clear();
            command.Parameters.Add("@ID", SqlDbType.Decimal).Value              = objAccountRolesInfo.ID;
            command.Parameters.Add("@Name", SqlDbType.NVarChar, 150).Value      = objAccountRolesInfo.Name;
            command.Parameters.Add("@Type", SqlDbType.NVarChar, 50).Value       = objAccountRolesInfo.Type;
            command.Parameters.Add("@Account_ID", SqlDbType.NVarChar, 50).Value = objAccountRolesInfo.Account_ID;
            command.Parameters.Add("@Value", SqlDbType.Decimal).Value           = objAccountRolesInfo.Value;
            command.Parameters.Add("@Seq", SqlDbType.Int).Value = objAccountRolesInfo.Seq;
            command.Parameters.Add("@Operator", SqlDbType.NVarChar, 50).Value = objAccountRolesInfo.Operator;
            command.Parameters.Add("@Active", SqlDbType.Bit).Value            = objAccountRolesInfo.Active;
            if (objAccountRolesInfo.Active)
            {
                command.Parameters.Add("@Active_Date", SqlDbType.DateTime).Value = objAccountRolesInfo.Active_Date;
            }
            else
            {
                command.Parameters.Add("@Active_Date", SqlDbType.DateTime).Value = DBNull.Value;
            }
            command.Parameters.Add("@CreateDate", SqlDbType.DateTime).Value      = objAccountRolesInfo.CreateDate;
            command.Parameters.Add("@Last_Update", SqlDbType.DateTime).Value     = objAccountRolesInfo.Last_Update;
            command.Parameters.Add("@UserCreated", SqlDbType.NVarChar, 25).Value = objAccountRolesInfo.UserCreated;
            this.AddCommand(command);
            return(command);
        }
Beispiel #6
0
        public new int Update(AccountRoles_Info acRoleInfo)
        {
            if (acRoleInfo == null)
            {
                SetError(98, "Invalid data input");
                return(Error_Number);
            }
            if (string.IsNullOrEmpty(acRoleInfo.Account_ID))
            {
                SetError(98, "Account_ID is null or empty");
                return(Error_Number);
            }
            if (string.IsNullOrEmpty(acRoleInfo.Name))
            {
                SetError(98, "Name is null or empty");
                return(Error_Number);
            }
            if (Convert.ToInt32(acRoleInfo.Seq) == 0)
            {
                SetError(98, "Seq is null or empty");
                return(Error_Number);
            }
            if (string.IsNullOrEmpty(acRoleInfo.Operator.ToString()))
            {
                SetError(98, "Operater is null or empty");
                return(Error_Number);
            }
            if (string.IsNullOrEmpty(acRoleInfo.Type.ToString()))
            {
                SetError(98, "Type is null or empty");
                return(Error_Number);
            }
            if ((acRoleInfo.Active == true) && (acRoleInfo.Active_Date == DateTime.MinValue))
            {
                SetError(98, "Active Date is null or empty");
                return(Error_Number);
            }
            if (acRoleInfo.CreateDate == DateTime.MinValue)
            {
                SetError(98, "CreateDate is null or empty");
                return(Error_Number);
            }
            if (acRoleInfo.Last_Update == DateTime.MinValue)
            {
                SetError(98, "Last_Update is null or empty");
                return(Error_Number);
            }
            if (string.IsNullOrEmpty(acRoleInfo.UserCreated))
            {
                SetError(98, "UserCreated is null or empty");
                return(Error_Number);
            }
            var oldAcRoleInfo = _dalAcRoles.GetOne(acRoleInfo.ID);

            if (oldAcRoleInfo == null)
            {
                SetError(99, string.Format("Account role {0} not find", acRoleInfo.ID));
                return(Error_Number);
            }
            if (base.Update(acRoleInfo) != 0)
            {
                SetError(0, String.Empty);
            }
            else
            {
                SetError(99, _dalAcRoles.GetException.Message);
            }

            return(Error_Number);
        }