Пример #1
0
//Convert DataTable To object method
        public jobtypeClass ConvertToOjbect(DataTable dt)
        {
            jobtypeClass obj_jobtype = new jobtypeClass();

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

                if (Convert.ToString(dt.Rows[i]["Jobtype"]) != "")
                {
                    obj_jobtype.Jobtype = Convert.ToString(dt.Rows[i]["Jobtype"]);
                }
                else
                {
                    obj_jobtype.Jobtype = Convert.ToString("");
                }
            }
            return(obj_jobtype);
        }
Пример #2
0
//Convert DataTable To List method
        public List <jobtypeClass> ConvertToList(DataTable dt)
        {
            List <jobtypeClass> jobtypelist = new List <jobtypeClass>();

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

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

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


                jobtypelist.Add(obj_jobtype);
            }
            return(jobtypelist);
        }
Пример #3
0
//create parameter
        public void createParameter(jobtypeClass obj, DB_con.DBTrans trans)
        {
            try
            {
                obj_con.clearParameter();
                obj_con.addParameter("@Jobtype", string.IsNullOrEmpty(Convert.ToString(obj.Jobtype)) ? "" : obj.Jobtype);
                obj_con.addParameter("@Jobtypeid", obj.Jobtypeid, trans);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #4
0
//Select Constructor
        public jobtypeCtl(Int32 id)
        {
            obj_con = new ConnectionCls();
            jobtypeClass obj_job = new jobtypeClass();

            using (DataTable dt = selectdatatable(id))
            {
                if (dt.Rows.Count > 0)
                {
                    obj_job.Jobtypeid = Convert.ToInt32(dt.Rows[0]["Jobtypeid"]);
                    obj_job.Jobtype   = Convert.ToString(dt.Rows[0]["Jobtype"]);
                }
            }
        }
Пример #5
0
 //insert data into database
 public Int32 insert(jobtypeClass obj)
 {
     try
     {
         obj_con.clearParameter();
         createParameter(obj, DBTrans.Insert);
         obj_con.BeginTransaction();
         obj_con.ExecuteNoneQuery("sp_jobtype_insert", CommandType.StoredProcedure);
         obj_con.CommitTransaction();
         return(obj.Jobtypeid = Convert.ToInt32(obj_con.getValue("@Jobtypeid")));
     }
     catch (Exception ex)
     {
         obj_con.RollbackTransaction();
         throw new Exception("sp_jobtype_insert");
     }
 }
Пример #6
0
//update edited object
        public jobtypeClass updateObject(jobtypeClass obj)
        {
            try
            {
                jobtypeClass oldObj = selectById(obj.Jobtypeid);
                if (obj.Jobtype == null || obj.Jobtype.ToString().Trim() == "update")
                {
                    obj.Jobtype = oldObj.Jobtype;
                }

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