Ejemplo n.º 1
0
        public int Update(string id, string name)
        {
            if (string.IsNullOrEmpty(id))
            {
                SetError(98, "Industry id is null or empty");
                return(Error_Number);
            }
            if (string.IsNullOrEmpty(name))
            {
                SetError(98, "Industry name is null or empty");
                return(Error_Number);
            }
            Industry_Info obj = base.GetIndustryByID(id);

            if (obj == null)
            {
                SetError(99, "Industry 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);
        }
Ejemplo n.º 2
0
        private static bool Validation(Industry_Info obj)
        {
            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);
            }
        }
Ejemplo n.º 3
0
        public int Insert(string id, string name)
        {
            if (string.IsNullOrEmpty(id))
            {
                SetError(98, "Industry id is null or empty");
                return(Error_Number);
            }
            if (string.IsNullOrEmpty(name))
            {
                SetError(98, "Industry name is null or empty");
                return(Error_Number);
            }
            Industry_Info obj = new Industry_Info();

            obj.ID   = id;
            obj.Name = name;
            if (base.Insert(obj) != 0)
            {
                SetError(0, String.Empty);
            }
            else
            {
                SetError(99, Error_Message);
            }
            return(Error_Number);
        }
Ejemplo n.º 4
0
        public SqlCommand EditOneIndustry(Industry_Info objIndustryInfo)
        {
            SqlCommand command = new SqlCommand("Update Industry Set  Name= @Name  Where ID= @ID");

            command.CommandType = CommandType.Text;
            command.Parameters.Add("@ID", SqlDbType.NVarChar, 5).Value     = objIndustryInfo.ID;
            command.Parameters.Add("@Name", SqlDbType.NVarChar, 135).Value = objIndustryInfo.Name;
            this.AddCommand(command);
            return(command);
        }
Ejemplo n.º 5
0
        public SqlCommand CreateOneIndustry(Industry_Info objIndustryInfo)
        {
            SqlCommand command = new SqlCommand("insert into Industry (ID, Name) Values (@ID, @Name)");

            command.CommandType = CommandType.Text;
            command.Parameters.Add("@ID", SqlDbType.NVarChar, 5).Value     = objIndustryInfo.ID;
            command.Parameters.Add("@Name", SqlDbType.NVarChar, 135).Value = objIndustryInfo.Name;
            this.AddCommand(command);
            return(command);
        }
Ejemplo n.º 6
0
 public static int Update(Industry_Info obj)
 {
     if (Validation(obj))
     {
         return(dalIn.Update(obj.ID, obj.Name));
     }
     else
     {
         throw new Exception(dalIn.Error_Message);
     }
 }
Ejemplo n.º 7
0
 protected int Delete(Industry_Info obj)
 {
     if (obj == null)
     {
         throw new Exception("Invalid data input");
     }
     _dalIn.RemoveOneIndustry(obj.ID);
     if (_dalIn.Execute())
     {
         return(_dalIn.LastRecordsEffected);
     }
     else
     {
         throw _dalIn.GetException;
     }
 }
Ejemplo n.º 8
0
        private Industry_Info GenerateObj(DataRow row)
        {
            if (row == null)
            {
                throw new Exception("Invalid Datarow");
            }
            Industry_Info inInfo = new Industry_Info();

            if (row["ID"] != DBNull.Value)
            {
                inInfo.ID = Convert.ToString(row["ID"]);
            }
            if (row["Name"] != DBNull.Value)
            {
                inInfo.Name = Convert.ToString(row["Name"]);
            }
            return(inInfo);
        }
Ejemplo n.º 9
0
        public int Delete(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                SetError(98, "Industry id is null or empty");
                return(Error_Number);
            }
            Industry_Info obj = base.GetIndustryByID(id);

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