예제 #1
0
//Convert DataTable To object method
        public systemtypeClass ConvertToOjbect(DataTable dt)
        {
            systemtypeClass obj_systemtype = new systemtypeClass();

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

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

                if (Convert.ToString(dt.Rows[i]["Systemelementtypename"]) != "")
                {
                    obj_systemtype.Systemelementtypename = Convert.ToString(dt.Rows[i]["Systemelementtypename"]);
                }
                else
                {
                    obj_systemtype.Systemelementtypename = Convert.ToString("");
                }
            }
            return(obj_systemtype);
        }
예제 #2
0
//create parameter
        public void createParameter(systemtypeClass obj, DB_con.DBTrans trans)
        {
            try
            {
                obj_con.clearParameter();
                obj_con.addParameter("@Systemelementid", string.IsNullOrEmpty(Convert.ToString(obj.Systemelementid)) ? 0 : obj.Systemelementid);
                obj_con.addParameter("@Systemelementtypename", string.IsNullOrEmpty(Convert.ToString(obj.Systemelementtypename)) ? "" : obj.Systemelementtypename);
                obj_con.addParameter("@Systemelementtypeid", obj.Systemelementtypeid, trans);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #3
0
//Select Constructor
        public systemtypeCtl(Int32 id)
        {
            obj_con = new ConnectionCls();
            systemtypeClass obj_sys = new systemtypeClass();

            using (DataTable dt = selectdatatable(id))
            {
                if (dt.Rows.Count > 0)
                {
                    obj_sys.Systemelementtypeid   = Convert.ToInt32(dt.Rows[0]["Systemelementtypeid"]);
                    obj_sys.Systemelementid       = Convert.ToInt32(dt.Rows[0]["Systemelementid"]);
                    obj_sys.Systemelementtypename = Convert.ToString(dt.Rows[0]["Systemelementtypename"]);
                }
            }
        }
예제 #4
0
 //insert data into database
 public Int32 insert(systemtypeClass obj)
 {
     try
     {
         obj_con.clearParameter();
         createParameter(obj, DBTrans.Insert);
         obj_con.BeginTransaction();
         obj_con.ExecuteNoneQuery("sp_systemtype_insert", CommandType.StoredProcedure);
         obj_con.CommitTransaction();
         return(obj.Systemelementtypeid = Convert.ToInt32(obj_con.getValue("@Systemelementtypeid")));
     }
     catch (Exception ex)
     {
         obj_con.RollbackTransaction();
         throw new Exception("sp_systemtype_insert");
     }
 }
예제 #5
0
//Convert DataTable To List method
        public List <systemtypeClass> ConvertToList(DataTable dt)
        {
            List <systemtypeClass> systemtypelist = new List <systemtypeClass>();

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

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

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

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


                systemtypelist.Add(obj_systemtype);
            }
            return(systemtypelist);
        }
예제 #6
0
//update edited object
        public systemtypeClass updateObject(systemtypeClass obj)
        {
            try
            {
                systemtypeClass oldObj = selectById(obj.Systemelementtypeid);
                if (obj.Systemelementid == null || obj.Systemelementid.ToString().Trim() == "0")
                {
                    obj.Systemelementid = oldObj.Systemelementid;
                }

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

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