Exemple #1
0
 //insert data into database
 public Int32 insert(locationClass obj)
 {
     try
     {
         obj_con.clearParameter();
         createParameter(obj, DBTrans.Insert);
         obj_con.BeginTransaction();
         obj_con.ExecuteNoneQuery("sp_location_insert", CommandType.StoredProcedure);
         obj_con.CommitTransaction();
         return(obj.Locationid = Convert.ToInt32(obj_con.getValue("@Locationid")));
     }
     catch (Exception ex)
     {
         obj_con.RollbackTransaction();
         throw new Exception("sp_location_insert");
     }
 }
Exemple #2
0
//create parameter
        public void createParameter(locationClass obj, DB_con.DBTrans trans)
        {
            try
            {
                obj_con.clearParameter();
                obj_con.addParameter("@Clientid", string.IsNullOrEmpty(Convert.ToString(obj.Clientid)) ? 0 : obj.Clientid);
                obj_con.addParameter("@Institutionid", string.IsNullOrEmpty(Convert.ToString(obj.Institutionid)) ? 0 : obj.Institutionid);
                obj_con.addParameter("@Building", string.IsNullOrEmpty(Convert.ToString(obj.Building)) ? "" : obj.Building);
                obj_con.addParameter("@Jobtypeid", string.IsNullOrEmpty(Convert.ToString(obj.Jobtypeid)) ? 0 : obj.Jobtypeid);
                obj_con.addParameter("@Jobstatusid", string.IsNullOrEmpty(Convert.ToString(obj.Jobstatusid)) ? 0 : obj.Jobstatusid);
                obj_con.addParameter("@Jobdetail", string.IsNullOrEmpty(Convert.ToString(obj.Jobdetail)) ? "" : obj.Jobdetail);
                obj_con.addParameter("@Locationid", obj.Locationid, trans);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #3
0
//Select Constructor
        public locationCtl(Int32 id)
        {
            obj_con = new ConnectionCls();
            locationClass obj_loc = new locationClass();

            using (DataTable dt = selectdatatable(id))
            {
                if (dt.Rows.Count > 0)
                {
                    obj_loc.Locationid    = Convert.ToInt32(dt.Rows[0]["Locationid"]);
                    obj_loc.Clientid      = Convert.ToInt32(dt.Rows[0]["Clientid"]);
                    obj_loc.Institutionid = Convert.ToInt32(dt.Rows[0]["Institutionid"]);
                    obj_loc.Building      = Convert.ToString(dt.Rows[0]["Building"]);
                    obj_loc.Jobtypeid     = Convert.ToInt32(dt.Rows[0]["Jobtypeid"]);
                    obj_loc.Jobstatusid   = Convert.ToInt32(dt.Rows[0]["Jobstatusid"]);
                    obj_loc.Jobdetail     = Convert.ToString(dt.Rows[0]["Jobdetail"]);
                }
            }
        }
Exemple #4
0
//update edited object
        public locationClass updateObject(locationClass obj)
        {
            try
            {
                locationClass oldObj = selectById(obj.Locationid);
                if (obj.Clientid == null || obj.Clientid.ToString().Trim() == "0")
                {
                    obj.Clientid = oldObj.Clientid;
                }

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

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

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

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

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

                return(obj);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemple #5
0
//Convert DataTable To object method
        public locationClass ConvertToOjbect(DataTable dt)
        {
            locationClass obj_location = new locationClass();

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

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

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

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

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

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

                if (Convert.ToString(dt.Rows[i]["Jobdetail"]) != "")
                {
                    obj_location.Jobdetail = Convert.ToString(dt.Rows[i]["Jobdetail"]);
                }
                else
                {
                    obj_location.Jobdetail = Convert.ToString("");
                }
            }
            return(obj_location);
        }
Exemple #6
0
//Convert DataTable To List method
        public List <locationClass> ConvertToList(DataTable dt)
        {
            List <locationClass> locationlist = new List <locationClass>();

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

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

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

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

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

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

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

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


                locationlist.Add(obj_location);
            }
            return(locationlist);
        }