Exemplo n.º 1
0
        //Convert DataTable To List method
        public List <WebsiteBannerClass> ConvertToList(DataTable dt)
        {
            List <WebsiteBannerClass> WebsiteBannerlist = new List <WebsiteBannerClass>();

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

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

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

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

                if (Convert.ToString(dt.Rows[i]["Isactive"]) != "")
                {
                    obj_WebsiteBanner.Isactive = Convert.ToBoolean(dt.Rows[i]["Isactive"]);
                }

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

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

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


                WebsiteBannerlist.Add(obj_WebsiteBanner);
            }
            return(WebsiteBannerlist);
        }
Exemplo n.º 2
0
        //Select Constructor
        public WebsiteBannerCtl(Int32?id)
        {
            obj_con = new ConnectionCls();
            WebsiteBannerClass obj_Web = new WebsiteBannerClass();

            using (DataTable dt = selectdatatable(id))
            {
                if (dt.Rows.Count > 0)
                {
                    obj_Web.Websitebannerid = Convert.ToInt32(dt.Rows[0]["Websitebannerid"]);
                    obj_Web.Bannername      = Convert.ToString(dt.Rows[0]["Bannername"]);
                    obj_Web.Isactive        = Convert.ToBoolean(dt.Rows[0]["Isactive"]);
                    obj_Web.Sequence        = Convert.ToInt32(dt.Rows[0]["Sequence"]);
                    obj_Web.Bannertextline1 = Convert.ToString(dt.Rows[0]["Bannertextline1"]);
                    obj_Web.Bannertextline2 = Convert.ToString(dt.Rows[0]["Bannertextline2"]);
                }
            }
        }
Exemplo n.º 3
0
 //update data into database
 public Int32?update(WebsiteBannerClass obj)
 {
     try
     {
         obj_con.clearParameter();
         obj = updateObject(obj);
         createParameter(obj, DBTrans.Update);
         obj_con.BeginTransaction();
         obj_con.ExecuteNoneQuery("sp_WebsiteBanner_update", CommandType.StoredProcedure);
         obj_con.CommitTransaction();
         return(obj.Websitebannerid = Convert.ToInt32(obj_con.getValue("@Websitebannerid")));
     }
     catch (Exception ex)
     {
         obj_con.RollbackTransaction();
         throw new Exception("sp_WebsiteBanner_update:" + ex.Message);
     }
 }
Exemplo n.º 4
0
        //Convert DataTable To object method
        public WebsiteBannerClass ConvertToOjbect(DataTable dt)
        {
            WebsiteBannerClass obj_WebsiteBanner = new WebsiteBannerClass();

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

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

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

                if (Convert.ToString(dt.Rows[i]["Isactive"]) != "")
                {
                    obj_WebsiteBanner.Isactive = Convert.ToBoolean(dt.Rows[i]["Isactive"]);
                }

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

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

                if (Convert.ToString(dt.Rows[i]["Bannertextline2"]) != "")
                {
                    obj_WebsiteBanner.Bannertextline2 = Convert.ToString(dt.Rows[i]["Bannertextline2"]);
                }
            }
            return(obj_WebsiteBanner);
        }
Exemplo n.º 5
0
        //update edited object
        public WebsiteBannerClass updateObject(WebsiteBannerClass obj)
        {
            try
            {
                WebsiteBannerClass oldObj = selectById(obj.Websitebannerid);
                if (obj.Bannername == null)
                {
                    obj.Bannername = oldObj.Bannername;
                }

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

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

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

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

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

                return(obj);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 6
0
        //create parameter
        public void createParameter(WebsiteBannerClass obj, DB_con.DBTrans trans)
        {
            try
            {
                obj_con.clearParameter();
                if (Convert.ToString(obj.Createdon) != "")
                {
                    obj_con.addParameter("@createdon", string.IsNullOrEmpty(Convert.ToString(obj.Createdon)) ? Convert.ToDateTime("1900-01-01") : obj.Createdon);
                }
                else
                {
                    obj_con.addParameter("@createdon", DBNull.Value);
                }

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

                if (Convert.ToString(obj.Isdeleted) != "")
                {
                    obj_con.addParameter("@isdeleted", string.IsNullOrEmpty(Convert.ToString(obj.Isdeleted)) ? false : obj.Isdeleted);
                }
                else
                {
                    obj_con.addParameter("@isdeleted", DBNull.Value);
                }
                if (Convert.ToString(obj.Deletedon) != "")
                {
                    obj_con.addParameter("@deletedon", string.IsNullOrEmpty(Convert.ToString(obj.Deletedon)) ? Convert.ToDateTime("1900-01-01") : obj.Deletedon);
                }
                else
                {
                    obj_con.addParameter("@deletedon", DBNull.Value);
                }

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

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

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


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

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

                if (Convert.ToString(obj.Sequence) != "")
                {
                    obj_con.addParameter("@Sequence", Convert.ToInt32(obj.Sequence));
                }
                else
                {
                    obj_con.addParameter("@Sequence", DBNull.Value);
                }
                if (Convert.ToString(obj.Websitebannerid) != "")
                {
                    obj_con.addParameter("@Websitebannerid", Convert.ToInt32(obj.Websitebannerid), trans);
                }
                else
                {
                    obj_con.addParameter("@Websitebannerid", DBNull.Value);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }