//update edited object
        public buildingdeficiencyrepairClass updateObject(buildingdeficiencyrepairClass obj)
        {
            try
            {
                buildingdeficiencyrepairClass oldObj = selectById(obj.Buildingdeficiencyrepairid);
                if (obj.Buildingid == null || obj.Buildingid.ToString().Trim() == "0")
                {
                    obj.Buildingid = oldObj.Buildingid;
                }

                if (obj.Description == null || obj.Description.ToString().Trim() == "update")
                {
                    obj.Description = oldObj.Description;
                }

                if (obj.Quantity == null || obj.Quantity.ToString().Trim() == "0")
                {
                    obj.Quantity = oldObj.Quantity;
                }

                if (obj.Units == null || obj.Units.ToString().Trim() == "0")
                {
                    obj.Units = oldObj.Units;
                }

                if (obj.Priority == null || obj.Priority.ToString().Trim() == "update")
                {
                    obj.Priority = oldObj.Priority;
                }

                if (obj.Note == null || obj.Note.ToString().Trim() == "update")
                {
                    obj.Note = oldObj.Note;
                }

                if (obj.Workareano == null || obj.Workareano.ToString().Trim() == "0")
                {
                    obj.Workareano = oldObj.Workareano;
                }

                if (obj.Userid == null || obj.Userid.ToString().Trim() == "0")
                {
                    obj.Userid = oldObj.Userid;
                }

                if (obj.Inserteddatetime == null || obj.Inserteddatetime == Convert.ToDateTime("1900-01-01"))
                {
                    obj.Inserteddatetime = oldObj.Inserteddatetime;
                }

                return(obj);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
 //insert data into database
 public Int32 insert(buildingdeficiencyrepairClass obj)
 {
     try
     {
         obj_con.clearParameter();
         createParameter(obj, DBTrans.Insert);
         obj_con.BeginTransaction();
         obj_con.ExecuteNoneQuery("sp_buildingdeficiencyrepair_insert", CommandType.StoredProcedure);
         obj_con.CommitTransaction();
         return(obj.Buildingdeficiencyrepairid = Convert.ToInt32(obj_con.getValue("@Buildingdeficiencyrepairid")));
     }
     catch (Exception ex)
     {
         obj_con.RollbackTransaction();
         throw new Exception("sp_buildingdeficiencyrepair_insert");
     }
 }
//create parameter
        public void createParameter(buildingdeficiencyrepairClass obj, DB_con.DBTrans trans)
        {
            try
            {
                obj_con.clearParameter();
                obj_con.addParameter("@Buildingid", string.IsNullOrEmpty(Convert.ToString(obj.Buildingid)) ? 0 : obj.Buildingid);
                obj_con.addParameter("@Description", string.IsNullOrEmpty(Convert.ToString(obj.Description)) ? "" : obj.Description);
                obj_con.addParameter("@Quantity", string.IsNullOrEmpty(Convert.ToString(obj.Quantity)) ? 0 : obj.Quantity);
                obj_con.addParameter("@Units", string.IsNullOrEmpty(Convert.ToString(obj.Units)) ? 0 : obj.Units);
                obj_con.addParameter("@Priority", string.IsNullOrEmpty(Convert.ToString(obj.Priority)) ? "" : obj.Priority);
                obj_con.addParameter("@Note", string.IsNullOrEmpty(Convert.ToString(obj.Note)) ? "" : obj.Note);
                obj_con.addParameter("@Workareano", string.IsNullOrEmpty(Convert.ToString(obj.Workareano)) ? 0 : obj.Workareano);
                obj_con.addParameter("@Userid", string.IsNullOrEmpty(Convert.ToString(obj.Userid)) ? 0 : obj.Userid);
                obj_con.addParameter("@Inserteddatetime", string.IsNullOrEmpty(Convert.ToString(obj.Inserteddatetime)) ? Convert.ToDateTime("1900-01-01") : obj.Inserteddatetime);
                obj_con.addParameter("@Buildingdeficiencyrepairid", obj.Buildingdeficiencyrepairid, trans);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
//Select Constructor
        public buildingdeficiencyrepairCtl(Int32 id)
        {
            obj_con = new ConnectionCls();
            buildingdeficiencyrepairClass obj_bui = new buildingdeficiencyrepairClass();

            using (DataTable dt = selectdatatable(id))
            {
                if (dt.Rows.Count > 0)
                {
                    obj_bui.Buildingdeficiencyrepairid = Convert.ToInt32(dt.Rows[0]["Buildingdeficiencyrepairid"]);
                    obj_bui.Buildingid       = Convert.ToInt32(dt.Rows[0]["Buildingid"]);
                    obj_bui.Description      = Convert.ToString(dt.Rows[0]["Description"]);
                    obj_bui.Quantity         = Convert.ToInt32(dt.Rows[0]["Quantity"]);
                    obj_bui.Units            = Convert.ToInt32(dt.Rows[0]["Units"]);
                    obj_bui.Priority         = Convert.ToString(dt.Rows[0]["Priority"]);
                    obj_bui.Note             = Convert.ToString(dt.Rows[0]["Note"]);
                    obj_bui.Workareano       = Convert.ToInt32(dt.Rows[0]["Workareano"]);
                    obj_bui.Userid           = Convert.ToInt32(dt.Rows[0]["Userid"]);
                    obj_bui.Inserteddatetime = Convert.ToDateTime(dt.Rows[0]["Inserteddatetime"]);
                }
            }
        }
//Convert DataTable To object method
        public buildingdeficiencyrepairClass ConvertToOjbect(DataTable dt)
        {
            buildingdeficiencyrepairClass obj_buildingdeficiencyrepair = new buildingdeficiencyrepairClass();

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

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

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

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

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

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

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

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

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

                if (Convert.ToString(dt.Rows[i]["Inserteddatetime"]) != "")
                {
                    obj_buildingdeficiencyrepair.Inserteddatetime = Convert.ToDateTime(dt.Rows[i]["Inserteddatetime"]);
                }
                else
                {
                    obj_buildingdeficiencyrepair.Inserteddatetime = Convert.ToDateTime("01/01/1900");
                }
            }
            return(obj_buildingdeficiencyrepair);
        }