//Convert DataTable To object method
        public componentClass ConvertToOjbect(DataTable dt)
        {
            componentClass obj_component = new componentClass();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (Convert.ToString(dt.Rows[i]["Componentid"]) != "")
                {
                    obj_component.Componentid = Convert.ToInt32(dt.Rows[i]["Componentid"]);
                }
                else
                {
                    obj_component.Componentid = Convert.ToInt32("0");
                }

                if (Convert.ToString(dt.Rows[i]["Componentname"]) != "")
                {
                    obj_component.Componentname = Convert.ToString(dt.Rows[i]["Componentname"]);
                }
                else
                {
                    obj_component.Componentname = Convert.ToString("");
                }
            }
            return(obj_component);
        }
//Convert DataTable To List method
        public List <componentClass> ConvertToList(DataTable dt)
        {
            List <componentClass> componentlist = new List <componentClass>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                componentClass obj_component = new componentClass();

                if (Convert.ToString(dt.Rows[i]["Componentid"]) != "")
                {
                    obj_component.Componentid = Convert.ToInt32(dt.Rows[i]["Componentid"]);
                }
                else
                {
                    obj_component.Componentid = Convert.ToInt32("0");
                }

                if (Convert.ToString(dt.Rows[i]["Componentname"]) != "")
                {
                    obj_component.Componentname = Convert.ToString(dt.Rows[i]["Componentname"]);
                }
                else
                {
                    obj_component.Componentname = Convert.ToString("");
                }


                componentlist.Add(obj_component);
            }
            return(componentlist);
        }
//create parameter
        public void createParameter(componentClass obj, DB_con.DBTrans trans)
        {
            try
            {
                obj_con.clearParameter();
                obj_con.addParameter("@Componentname", string.IsNullOrEmpty(Convert.ToString(obj.Componentname)) ? "" : obj.Componentname);
                obj_con.addParameter("@Componentid", obj.Componentid, trans);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
//Select Constructor
        public componentCtl(Int32 id)
        {
            obj_con = new ConnectionCls();
            componentClass obj_com = new componentClass();

            using (DataTable dt = selectdatatable(id))
            {
                if (dt.Rows.Count > 0)
                {
                    obj_com.Componentid   = Convert.ToInt32(dt.Rows[0]["Componentid"]);
                    obj_com.Componentname = Convert.ToString(dt.Rows[0]["Componentname"]);
                }
            }
        }
 //insert data into database
 public Int32 insert(componentClass obj)
 {
     try
     {
         obj_con.clearParameter();
         createParameter(obj, DBTrans.Insert);
         obj_con.BeginTransaction();
         obj_con.ExecuteNoneQuery("sp_component_insert", CommandType.StoredProcedure);
         obj_con.CommitTransaction();
         return(obj.Componentid = Convert.ToInt32(obj_con.getValue("@Componentid")));
     }
     catch (Exception ex)
     {
         obj_con.RollbackTransaction();
         throw new Exception("sp_component_insert");
     }
 }
//update edited object
        public componentClass updateObject(componentClass obj)
        {
            try
            {
                componentClass oldObj = selectById(obj.Componentid);
                if (obj.Componentname == null || obj.Componentname.ToString().Trim() == "update")
                {
                    obj.Componentname = oldObj.Componentname;
                }

                return(obj);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }