Esempio n. 1
0
 private static bool Validation(Sector_Info obj)
 {
     // reset temp string
     bstr = new StringBuilder("");
     if (obj == null)
     {
         bstr.Append("Invalid object\n");
     }
     if (string.IsNullOrEmpty(obj.ID))
     {
         bstr.Append("ID is null or empty\n");
     }
     if (string.IsNullOrEmpty(obj.Name))
     {
         bstr.Append("Name is null or empty\n");
     }
     if (string.IsNullOrEmpty(bstr.ToString()))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 2
0
        public int Update(string id, string name)
        {
            if (string.IsNullOrEmpty(id))
            {
                SetError(98, "Sector id is null or empty");
                return(Error_Number);
            }
            if (string.IsNullOrEmpty(name))
            {
                SetError(98, "Sector name is null or empty");
                return(Error_Number);
            }
            Sector_Info obj = base.GetSectorByID(id);

            if (obj == null)
            {
                SetError(99, "Sector not find");
                return(Error_Number);
            }
            obj.Name = name;
            if (base.Update(obj) != 0)
            {
                SetError(0, String.Empty);
            }
            else
            {
                SetError(99, Error_Message);
            }
            return(Error_Number);
        }
Esempio n. 3
0
        public int Insert(string id, string name)
        {
            if (string.IsNullOrEmpty(id))
            {
                SetError(98, "Sector id is null or empty");
                return(Error_Number);
            }
            if (string.IsNullOrEmpty(name))
            {
                SetError(98, "Sector name is null or empty");
                return(Error_Number);
            }
            Sector_Info obj = new Sector_Info();

            obj.ID   = id;
            obj.Name = name;
            if (base.Insert(obj) != 0)
            {
                SetError(0, String.Empty);
            }
            else
            {
                SetError(99, Error_Message);
            }
            return(Error_Number);
        }
Esempio n. 4
0
        public SqlCommand EditOneSector(Sector_Info objSectorInfo)
        {
            SqlCommand command = new SqlCommand("Update Sector Set  ID= @ID,Name= @Name Where ID= @ID");

            command.CommandType = CommandType.Text;
            command.Parameters.Add("@ID", SqlDbType.NVarChar, 5).Value     = objSectorInfo.ID;
            command.Parameters.Add("@Name", SqlDbType.NVarChar, 135).Value = objSectorInfo.Name;
            this.AddCommand(command);
            return(command);
        }
Esempio n. 5
0
        public SqlCommand CreateOneSector(Sector_Info objSectorInfo)
        {
            SqlCommand command = new SqlCommand("insert into Sector (ID, Name) Values (@ID, @Name)");

            command.CommandType = CommandType.Text;
            command.Parameters.Add("@ID", SqlDbType.NVarChar, 5).Value     = objSectorInfo.ID;
            command.Parameters.Add("@Name", SqlDbType.NVarChar, 135).Value = objSectorInfo.Name;
            this.AddCommand(command);
            return(command);
        }
Esempio n. 6
0
 public static int Update(Sector_Info obj)
 {
     if (Validation(obj))
     {
         return(dalSec.Update(obj.ID, obj.Name));
     }
     else
     {
         throw new Exception(dalSec.Error_Message);
     }
 }
Esempio n. 7
0
 protected int Delete(Sector_Info obj)
 {
     if (obj == null)
     {
         throw new Exception("Invalid data input");
     }
     _dalSec.RemoveOneSector(obj.ID);
     if (_dalSec.Execute())
     {
         return(_dalSec.LastRecordsEffected);
     }
     else
     {
         throw _dalSec.GetException;
     }
 }
Esempio n. 8
0
        private Sector_Info GenerateObj(DataRow row)
        {
            if (row == null)
            {
                throw new Exception("Invalid Datarow");
            }
            Sector_Info objSec = new Sector_Info();

            if (row["ID"] == DBNull.Value)
            {
                objSec.ID = Convert.ToString(row["ID"]);
            }
            if (row["Name"] == DBNull.Value)
            {
                objSec.ID = Convert.ToString(row["Name"]);
            }
            return(objSec);
        }
Esempio n. 9
0
        public int Delete(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                SetError(98, "Sector id is null or empty");
                return(Error_Number);
            }
            Sector_Info obj = base.GetSectorByID(id);

            if (obj == null)
            {
                SetError(99, "Sector not find");
                return(Error_Number);
            }
            if (base.Delete(obj) != 0)
            {
                SetError(0, string.Empty);
            }
            else
            {
                SetError(99, Error_Message);
            }
            return(Error_Number);
        }