//Convert DataTable To object method
        public buildingsystemClass ConvertToOjbect(DataTable dt)
        {
            buildingsystemClass obj_buildingsystem = new buildingsystemClass();

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

                if (Convert.ToString(dt.Rows[i]["Buildingsystemname"]) != "")
                {
                    obj_buildingsystem.Buildingsystemname = Convert.ToString(dt.Rows[i]["Buildingsystemname"]);
                }
                else
                {
                    obj_buildingsystem.Buildingsystemname = Convert.ToString("");
                }
            }
            return(obj_buildingsystem);
        }
//Convert DataTable To List method
        public List <buildingsystemClass> ConvertToList(DataTable dt)
        {
            List <buildingsystemClass> buildingsystemlist = new List <buildingsystemClass>();

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

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

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


                buildingsystemlist.Add(obj_buildingsystem);
            }
            return(buildingsystemlist);
        }
//create parameter
        public void createParameter(buildingsystemClass obj, DB_con.DBTrans trans)
        {
            try
            {
                obj_con.clearParameter();
                obj_con.addParameter("@Buildingsystemname", string.IsNullOrEmpty(Convert.ToString(obj.Buildingsystemname)) ? "" : obj.Buildingsystemname);
                obj_con.addParameter("@Buildingsystemid", obj.Buildingsystemid, trans);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
//Select Constructor
        public buildingsystemCtl(Int32 id)
        {
            obj_con = new ConnectionCls();
            buildingsystemClass obj_bui = new buildingsystemClass();

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

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