Example #1
0
//Convert DataTable To List method
        public List <GeneralSettingsClass> ConvertToList(DataTable dt)
        {
            List <GeneralSettingsClass> GeneralSettingslist = new List <GeneralSettingsClass>();

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

                if (Convert.ToString(dt.Rows[i]["Generalsettings"]) != "")
                {
                    obj_GeneralSettings.Generalsettings = Convert.ToInt32(dt.Rows[i]["Generalsettings"]);
                }

                if (Convert.ToString(dt.Rows[i]["Key"]) != "")
                {
                    obj_GeneralSettings.Key = Convert.ToString(dt.Rows[i]["Key"]);
                }

                if (Convert.ToString(dt.Rows[i]["Descrpition"]) != "")
                {
                    obj_GeneralSettings.Descrpition = Convert.ToString(dt.Rows[i]["Descrpition"]);
                }


                GeneralSettingslist.Add(obj_GeneralSettings);
            }
            return(GeneralSettingslist);
        }
Example #2
0
//Select Constructor
        public GeneralSettingsCtl(Int32?id)
        {
            obj_con = new ConnectionCls();
            GeneralSettingsClass obj_Gen = new GeneralSettingsClass();

            using (DataTable dt = selectdatatable(id))
            {
                if (dt.Rows.Count > 0)
                {
                    obj_Gen.Generalsettings = Convert.ToInt32(dt.Rows[0]["Generalsettings"]);
                    obj_Gen.Key             = Convert.ToString(dt.Rows[0]["Key"]);
                    obj_Gen.Descrpition     = Convert.ToString(dt.Rows[0]["Descrpition"]);
                }
            }
        }
Example #3
0
 //insert data into database
 public Int32?insert(GeneralSettingsClass obj)
 {
     try
     {
         obj_con.clearParameter();
         createParameter(obj, DBTrans.Insert);
         obj_con.BeginTransaction();
         obj_con.ExecuteNoneQuery("sp_GeneralSettings_insert", CommandType.StoredProcedure);
         obj_con.CommitTransaction();
         return(obj.Generalsettings = Convert.ToInt32(obj_con.getValue("@Generalsettings")));
     }
     catch (Exception ex)
     {
         obj_con.RollbackTransaction();
         throw new Exception("sp_GeneralSettings_insert:" + ex.Message);
     }
 }
Example #4
0
//update edited object
        public GeneralSettingsClass updateObject(GeneralSettingsClass obj)
        {
            try
            {
                GeneralSettingsClass oldObj = selectById(obj.Generalsettings);
                if (obj.Key == null)
                {
                    obj.Key = oldObj.Key;
                }

                if (obj.Descrpition == null)
                {
                    obj.Descrpition = oldObj.Descrpition;
                }

                return(obj);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #5
0
//create parameter
        public void createParameter(GeneralSettingsClass obj, DB_con.DBTrans trans)
        {
            try
            {
                obj_con.clearParameter();

                if (Convert.ToString(obj.Key) != "")
                {
                    obj_con.addParameter("@Key", string.IsNullOrEmpty(Convert.ToString(obj.Key)) ? "" : obj.Key);
                }
                else
                {
                    obj_con.addParameter("@Key", DBNull.Value);
                }

                if (Convert.ToString(obj.Descrpition) != "")
                {
                    obj_con.addParameter("@Descrpition", string.IsNullOrEmpty(Convert.ToString(obj.Descrpition)) ? "" : obj.Descrpition);
                }
                else
                {
                    obj_con.addParameter("@Descrpition", DBNull.Value);
                }

                if (Convert.ToString(obj.Generalsettings) != "")
                {
                    obj_con.addParameter("@Generalsettings", Convert.ToInt32(obj.Generalsettings), trans);
                }
                else
                {
                    obj_con.addParameter("@Generalsettings", DBNull.Value);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #6
0
//Convert DataTable To object method
        public GeneralSettingsClass ConvertToOjbect(DataTable dt)
        {
            GeneralSettingsClass obj_GeneralSettings = new GeneralSettingsClass();

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

                if (Convert.ToString(dt.Rows[i]["Key"]) != "")
                {
                    obj_GeneralSettings.Key = Convert.ToString(dt.Rows[i]["Key"]);
                }

                if (Convert.ToString(dt.Rows[i]["Descrpition"]) != "")
                {
                    obj_GeneralSettings.Descrpition = Convert.ToString(dt.Rows[i]["Descrpition"]);
                }
            }
            return(obj_GeneralSettings);
        }