Ejemplo n.º 1
0
        private void GetVideo()
        {
            try
            {
                string categoryID = null;
                categoryID = GetProductCategory();
                ProductBLL          pcBll = new ProductBLL();
                IList <PNK_Product> lst   = null;

                DataTable dtb   = DBHelper.ExcuteFromCmd("SELECT * FROM dbo.fc_GetAllChildProductCategory(" + categoryID + ",1)", null);
                string[]  array = dtb.AsEnumerable()
                                  .Select(row => row.Field <Int32>("id").ToString())
                                  .ToArray();
                string idFirst = string.Join(",", array);

                lst = pcBll.GetList(LangInt, string.Empty, "1", idFirst, string.Empty, string.Empty, "1", string.Empty, string.Empty, currentPageIndex, DBConvert.ParseInt(ConfigurationManager.AppSettings["pageSizeCate"]), out total);
                if (lst.Count > 0)
                {
                    // ifrTop.Attributes.Add("src", "//www.youtube.com/embed/" + UtilityLocal.GetVideoList(lst[0].Id) + "?rel=0&amp;autoplay=0");

                    this.records              = DBConvert.ParseString(total);
                    this.pager.PageSize       = DBConvert.ParseInt(ConfigurationManager.AppSettings["pageSizeCate"]);
                    this.pager.ItemCount      = total;
                    this.rptResult.DataSource = lst;
                    this.rptResult.DataBind();
                }
            }
            catch (Exception ex)
            {
                Write2Log.WriteLogs("GetVideo", "GetProduct", ex.Message);
            }
        }
Ejemplo n.º 2
0
        public int Insert(T obj, List <TDesc> lst)
        {
            IFactory factory = DBHelper.CreateFactory();

            factory.BeginTransaction();
            int output = 0;

            try
            {
                output = dal.InsertWithTransaction(obj, factory);
                foreach (var item in lst)
                {
                    item.GetType().GetProperty("MainId").SetValue(item, output, null);
                    dalDesc.InsertWithTransaction(item, factory);
                }
                factory.Commit();
            }
            catch (Exception ex)
            {
                Write2Log.WriteLogs("Generic2C<T, TDesc>", string.Format("Insert({0} obj, List<TDesc> lst)", obj.GetType().Name), ex.Message);
                factory.Rollback();
            }
            finally
            {
                factory.Release();
            }
            return(output);
        }
Ejemplo n.º 3
0
        public T LoadByObjectAndLang(int objId, int langId)
        {
            IList <T> sessions = new List <T>();
            IFactory  factory  = DBHelper.CreateFactory();

            try
            {
                string    query = string.Format(@"Select * from {0} where MainId = {1}MainId and LangId = {1}LangId", typeof(T).Name, PARAM_PREFIX);
                DbCommand cmd   = factory.MakeCommand(query);
                DGCDataParameter.AddParameter(cmd, string.Format("{0}MainId", PARAM_PREFIX), DbType.Int32, objId);
                DGCDataParameter.AddParameter(cmd, string.Format("{0}LangId", PARAM_PREFIX), DbType.Int32, langId);
                IDataReader dre = factory.ExecuteReader(cmd);
                sessions = Results(dre);
                if (sessions.Count > 0)
                {
                    return(sessions[0]);
                }
            }
            catch (Exception ex)
            {
                Write2Log.WriteLogs("Generic<T>", string.Format("{0} LoadByObjectAndLang(int objId, int langId)", typeof(T).Name), ex.Message);
            }
            finally
            {
                factory.Release();
            }
            return(null);
        }
Ejemplo n.º 4
0
        public T Load(T obj, string[] primaryKeyNames)
        {
            IList <T> sessions = new List <T>();
            IFactory  factory  = DBHelper.CreateFactory();
            DbCommand cmd      = null;

            try
            {
                string query = GenerateQuery.CommandTextLoad(obj, primaryKeyNames);
                cmd = factory.MakeCommand(query);
                GenerateQuery.PrepareParametersLoad(cmd, obj, primaryKeyNames);
                IDataReader dre = factory.ExecuteReader(cmd);
                sessions = Results(dre);
                if (sessions.Count > 0)
                {
                    return(sessions[0]);
                }
            }
            catch (Exception ex)
            {
                Write2Log.WriteLogs("Generic<T>", string.Format("Load({0} obj, string[] primaryKeyNames)", typeof(T).Name), ex.Message);
            }
            finally
            {
                cmd.Connection.Close();
                cmd.Connection.Dispose();
            }
            return(default(T));
        }
Ejemplo n.º 5
0
        public int InsertIDENTITY(T obj)
        {
            IFactory factory = DBHelper.CreateFactory();

            factory.BeginTransaction();
            object output = null;
            int    re     = int.MinValue;

            try
            {
                string    query = GenerateQuery.CommandTextInsertIDENTITY(obj);
                DbCommand cmd   = factory.MakeCommand(query);
                GenerateQuery.PrepareParametersInsert(cmd, obj);
                output = factory.ExecuteScalar(cmd);
                factory.Commit();
                re = DBConvert.ParseInt(output);
            }
            catch (Exception ex)
            {
                Write2Log.WriteLogs("Generic<T>", string.Format("Insert({0} obj)", obj.GetType().Name), ex.Message);
                factory.Rollback();
            }
            finally
            {
                factory.Release();
            }
            return(re);
        }
Ejemplo n.º 6
0
        public IList <T> Results(IDataReader dre)
        {
            IList <T> sessions = new List <T>();

            PropertyInfo[] properties;
            try
            {
                while (dre.Read())
                {
                    T obj = new T();
                    properties = obj.GetType().GetProperties();

                    foreach (var property in properties)
                    {
                        property.SetValue(obj, DBConvert.ParseDBToObject(dre, property), null);
                    }
                    sessions.Add(obj);
                }
            }

            catch (Exception ex)
            {
                Write2Log.WriteLogs("Generic<T>", string.Format("IList<{0}> Results(IDataReader dre)", typeof(T).Name), ex.Message);
            }

            finally
            {
                dre.Close();
            }
            return(sessions);
        }
Ejemplo n.º 7
0
        private void GetConstruction()
        {
            try
            {
                ProductBLL pcBll = new ProductBLL();
                DataTable  dtb   = DBHelper.ExcuteFromCmd("SELECT * FROM dbo.fc_GetAllChildProductCategory(" + ConfigurationManager.AppSettings["parentIdTemplate"] + ",1)", null);
                if (dtb != null && dtb.Rows.Count > 0)
                {
                    string[] array = dtb.AsEnumerable()
                                     .Select(row => row.Field <Int32>("id").ToString())
                                     .ToArray();
                    string idFirst          = string.Join(",", array);
                    IList <PNK_Product> lst = pcBll.GetList(LangInt, string.Empty, "1", idFirst, string.Empty, string.Empty, string.Empty, 1, 2, out total);
                    if (lst.Count > 0)
                    {
                        this.rptConstruction.DataSource = lst;
                        this.rptConstruction.DataBind();
                    }
                }

                ProductCategoryBLL          pcBllCate = new ProductCategoryBLL();
                IList <PNK_ProductCategory> lstCate   = pcBllCate.GetList(LangInt, string.Empty, "1", DBConvert.ParseInt(ConfigurationManager.AppSettings["parentIdTemplate"]), int.MinValue, false, string.Empty, 1, 1, out total);
                if (lstCate.Count > 0)
                {
                    ltrConstructionCateName.Text = lstCate[0].ProductCategoryDesc.Name;
                }
            }
            catch (Exception ex)
            {
                Write2Log.WriteLogs("home", "GetProject", ex.Message);
            }
        }
Ejemplo n.º 8
0
        public static string GetPathTreeNameUrl(int categoryID, int langInt, string langId)
        {
            string result = string.Empty, id = string.Empty, pathTreeSub = string.Empty;

            try
            {
                ProductCategoryBLL          pcBll = new ProductCategoryBLL();
                IList <PNK_ProductCategory> lst   = pcBll.GetList(langInt, string.Empty, string.Empty, categoryID, int.MinValue, false, string.Empty, 1, 9999, out total);
                if (total > 0)
                {
                    string pathTree = lst[0].PathTree;
                    int    level    = pathTree.Count(i => i.Equals('.'));
                    for (int i = 1; i <= level; i++)
                    {
                        pathTreeSub = pathTree.Split('.')[i];
                        id          = pathTreeSub.Split('-')[1];
                        lst         = pcBll.GetList(langInt, string.Empty, string.Empty, int.Parse(id), int.MinValue, false, string.Empty, 1, 9999, out total);

                        result = result + (total > 0 ? lst[0].ProductCategoryDesc.NameUrl : string.Empty) + "/";

                        if (i == 1)
                        {
                            result = result + langId + "/";
                        }
                    }
                    result = result == "" ? "" : result.Remove(result.LastIndexOf('/'), 1);
                }
            }
            catch (Exception ex)
            {
                Write2Log.WriteLogs("Home Page", "GetPathTreeNameUrl", ex.Message);
            }

            return(result);
        }
Ejemplo n.º 9
0
        private void LoadGMap(string latitude, string longitude, string companyName, string address, string imageName)
        {
            try
            {
                PinIcon     p;
                GMarker     gm;
                GInfoWindow win;

                GLatLng         mainLocation = new GLatLng(DBConvert.ParseDouble(latitude), DBConvert.ParseDouble(longitude));
                GMapType.GTypes maptype      = GMapType.GTypes.Normal;
                GMap1.setCenter(mainLocation, 15, maptype);
                GMap1.enableHookMouseWheelToZoom = true;

                GMapUIOptions options = new GMapUIOptions();
                options.maptypes_hybrid  = true;
                options.maptypes_normal  = true;
                options.zoom_scrollwheel = true;
                GMap1.Add(new GMapUI(options));

                //GMarker marker = new GMarker(mainLocation);
                GIcon icon = new GIcon();
                icon.markerIconOptions = new MarkerIconOptions(50, 50, Color.Blue);
                p   = new PinIcon(PinIcons.home, Color.Cyan);
                gm  = new GMarker(mainLocation, new GMarkerOptions(new GIcon(p.ToString(), p.Shadow())));
                win = new GInfoWindow(gm, HtmlIconMap(imageName, companyName, address), false, GListener.Event.mouseover);
                GMap1.Add(win);
            }
            catch (Exception ex)
            {
                Write2Log.WriteLogs("block_googlemap", "LoadGMap", ex.Message);
            }
        }
Ejemplo n.º 10
0
        public bool Delete(string arrId)
        {
            IFactory factory  = DBHelper.CreateFactory();
            bool     isDelete = false;

            factory.BeginTransaction();
            try
            {
                string    query = string.Format(@"DELETE FROM {0} WHERE  Id in ({1})", typeof(T).Name.ToLower(), arrId);
                DbCommand cmd   = factory.MakeCommand(query);
                factory.ExecuteNonQuery(cmd);

                query = string.Format(@"DELETE FROM {0} WHERE  MainId in ({1})", typeof(TDesc).Name.ToLower(), arrId);
                cmd   = factory.MakeCommand(query);
                factory.ExecuteNonQuery(cmd);

                factory.Commit();
                isDelete = true;
            }
            catch (Exception ex)
            {
                Write2Log.WriteLogs("Generic2C<T, TDesc>", string.Format("Delete<{0}, TDesc>(string arrId)", typeof(T).Name), ex.Message);
                factory.Rollback();
            }
            finally
            {
                factory.Release();
            }
            return(isDelete);
        }
Ejemplo n.º 11
0
        protected void btnSend_ServerClick(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    bool   result  = false;
                    string path    = Request.PhysicalApplicationPath;
                    string strHtml = WebUtils.GetMailTemplate(Path.Combine(path, "TemplateMail/Contact.txt"));
                    string body    = string.Format(strHtml, "admin", txtFullName.Value, txtEmail.Value, txtMessage.Value);
                    result = WebUtils.SendEmail("Contact", txtEmail.Value, string.Empty, body);

                    if (result == true)
                    {
                        ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), Guid.NewGuid().ToString(), string.Format("jAlert('Send success.','Message',function(r) {{window.location='{0}'}});", Request.RawUrl), true);
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), Guid.NewGuid().ToString(), string.Format("jAlert('Send fail.','Message',function(r) {{window.location='{0}'}});", Request.RawUrl), true);
                    }
                    txtEmail.Value = txtMessage.Value = txtFullName.Value = "";
                }
            }
            catch (Exception ex)
            {
                Write2Log.WriteLogs("btnSend_ServerClick.aspx", "Contact", ex.Message);
            }
        }
Ejemplo n.º 12
0
        private void GetProduct(string categoryID)
        {
            try
            {
                categoryID = categoryIdByPass == string.Empty ? categoryID : categoryIdByPass;

                ProductBLL pcBll = new ProductBLL();
                Dictionary<string, object> dic = Common.UtilityLocal.GetProduct(pageName, categoryID, level, LangInt, currentPageIndex, DBConvert.ParseInt(ConfigurationManager.AppSettings["pageSizeCate"]));
                if (dic != null && dic.Count > 0)
                {
                    IList<PNK_Product> lst = dic["DictProduct"] as IList<PNK_Product>;
                    if (lst.Count > 0)
                    {
                        this.records = dic["DictProduct_Total"].ToString();
                        this.pager.PageSize = DBConvert.ParseInt(ConfigurationManager.AppSettings["pageSizeCate"]);
                        this.pager.ItemCount = DBConvert.ParseDouble(dic["DictProduct_Total"].ToString());

                        this.rptResult.DataSource = lst;
                        this.rptResult.DataBind();
                    }
                }
            }
            catch (Exception ex)
            {
                Write2Log.WriteLogs("block_category", "GetProduct", ex.Message);
            }
        }
Ejemplo n.º 13
0
        public IList <T> GetList(string storedProc, DGCParameter[] parameters, out int total)
        {
            total = 0;

            IFactory  factory = DBHelper.CreateFactory();
            IList <T> lst     = new List <T>();

            try
            {
                DbCommand cmd = factory.MakeCommandFromStore(storedProc);
                GenerateQuery.PrepareParametersList(cmd, parameters);

                IDbDataParameter para = cmd.CreateParameter();
                para.ParameterName = "@total";
                para.DbType        = DbType.Int32;
                para.Direction     = ParameterDirection.Output;
                para.Value         = total;
                cmd.Parameters.Add(para);

                IDataReader dre = factory.ExecuteReader(cmd);
                lst = Results(dre);
                object strTemp = cmd.Parameters["@total"].Value;
                total = Convert.ToInt32(strTemp);
            }
            catch (Exception ex)
            {
                Write2Log.WriteLogs("Generic2C<T, TDesc>", string.Format("GetList(string storedProc, DGCParameter[] parameters, out {0} obj, out TDesc objDesc, out int total)", typeof(T).Name), ex.Message);
            }
            finally
            {
                factory.Release();
            }
            return(lst);
        }
Ejemplo n.º 14
0
        private void GetVideo()
        {
            try
            {
                ProductBLL pcBll = new ProductBLL();

                DataTable dtbHot   = DBHelper.ExcuteFromCmd("SELECT * FROM dbo.fc_GetAllChildProductCategory(" + ConfigurationManager.AppSettings["parentIdVideo"] + ",1)", null);
                string[]  arrayHot = dtbHot.AsEnumerable()
                                     .Select(row => row.Field <Int32>("id").ToString())
                                     .ToArray();
                string idFirstHot = string.Join(",", arrayHot);
                if (idFirstHot != "" && idFirstHot != null)
                {
                    IList <PNK_Product> lstHot = pcBll.GetList(LangInt, string.Empty, "1", idFirstHot, string.Empty, string.Empty, string.Empty, 1, 9999, out total);
                    lstHot = lstHot.Where(m => m.Feature == "1").ToList();
                    if (lstHot.Count() > 0)
                    {
                        if (total > 0)
                        {
                            rptVideoTop.DataSource = lstHot;
                            rptVideoTop.DataBind();

                            rptVideo.DataSource = lstHot;
                            rptVideo.DataBind();
                            ifrTop.Attributes.Add("src", "//www.youtube.com/embed/" + UtilityLocal.GetVideoList(lstHot[0].Id) + "?rel=0&amp;autoplay=0");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Write2Log.WriteLogs("block_featuredvideo", "GetVideo", ex.Message);
            }
        }
Ejemplo n.º 15
0
        private void GetProductSale()
        {
            try
            {
                DataTable dtb   = DBHelper.ExcuteFromCmd("SELECT * FROM dbo.fc_GetAllChildProductCategory(" + categoryID + ",1)", null);
                string[]  array = dtb.AsEnumerable()
                                  .Select(row => row.Field <Int32>("id").ToString())
                                  .ToArray();
                string idFirst = string.Join(",", array);

                pcBll = new ProductBLL();
                IList <PNK_Product> lstAll = pcBll.GetList(LangInt, string.Empty, "1", idFirst, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, currentPageIndex, 9999, out total);
                if (lstAll.Count > 0)
                {
                    //lst = lst.Where(m => m.Promotion == "1").ToList();
                    rptProductHot.DataSource = lstAll.Where(m => m.Hot == "1").ToList();
                    rptProductHot.DataBind();

                    rptProductSale.DataSource = lstAll.Where(m => m.Promotion == "1").ToList();
                    rptProductSale.DataBind();
                }
            }
            catch (Exception ex)
            {
                Write2Log.WriteLogs("GetProductHot", "GetProduct", ex.Message);
            }
        }
Ejemplo n.º 16
0
        public T Load(T obj, string[] primaryKeyNames, int langId)
        {
            Type     t       = typeof(T);
            IFactory factory = DBHelper.CreateFactory();

            try
            {
                obj = dal.Load(obj, primaryKeyNames, factory);
                string[] fields = { "MainId", "LangId" };


                PropertyInfo property = t.GetProperty(("Id"));
                int          id       = Convert.ToInt32(property.GetValue(obj, null));
                TDesc        objDesc  = dalDesc.LoadByObjectAndLang(id, langId, factory);
                property = t.GetProperty(Utils.GetPropertyDescName(typeof(TDesc)));
                property.SetValue(obj, objDesc, null);
            }
            catch (Exception ex)
            {
                Write2Log.WriteLogs("Generic2C<T, TDesc>", string.Format("Load({0} obj, string[] primaryKeyNames, int langId, out TDesc objDesc)", t.Name), ex.Message);
            }
            finally
            {
                factory.Release();
            }
            return(obj);
        }
Ejemplo n.º 17
0
        private void GetPageName(string pageName)
        {
            try
            {
                cid    = Utils.GetParameter("cid", string.Empty);
                cidsub = Utils.GetParameter("cidsub", string.Empty);
                id     = Utils.GetParameter("id", string.Empty);

                if (pageName == "booking")
                {
                    pagePath         = "Pages/BookingManagement/Booking.ascx";
                    Session["level"] = 1;
                }

                else
                {
                    string             cateName  = string.Empty;
                    ProductCategoryBLL pcBllCate = new ProductCategoryBLL();
                    cateName = Common.UtilityLocal.GetCateNameByLevel(pageName, cid, cidsub, id);
                    IList <PNK_ProductCategory> lstCate = pcBllCate.GetList(LangInt, cateName, string.Empty, int.MinValue, false, "p.ordering", 1, 9999, out total);
                    if (total > 0)
                    {
                        pagePath         = lstCate[0].Page;
                        Session["level"] = lstCate[0].PathTree.Count(i => i.Equals('.'));
                    }

                    if (lstCate == null || total == 0)
                    {
                        ProductBLL pcBll = new ProductBLL();
                        cid    = cid != LocalizationUtility.GetText("linkCate", Ci) ? cid : string.Empty;
                        cidsub = cidsub != LocalizationUtility.GetText("linktmp", Ci) ? cidsub : string.Empty;
                        IList <PNK_Product> lst = pcBll.GetList(LangInt, cidsub, string.Empty, string.Empty, id, null, string.Empty, 1, 9999, out total);
                        if (total > 0)
                        {
                            //set page đặc biệt khi level=4 mà thiếu cid, cidsub
                            if (cid == LocalizationUtility.GetText("linkCate", Ci) || cid == LocalizationUtility.GetText("linktmp", Ci))
                            {
                                lst = lst.Where(p => p.ProductDesc.TitleUrl == id && p.CategoryUrlDesc == pageName).ToList();
                            }
                            else
                            {
                                lst = lst.Where(p => p.ProductDesc.TitleUrl == id).ToList();
                            }
                            if (lst.Count > 0)
                            {
                                string pagePathProduct = Common.UtilityLocal.GetPathTreeNameUrl(lst[0].Id, LangInt, LangId);
                                pagePath         = lst[0].Page;
                                Session["level"] = 3;
                            }
                        }
                    }
                }
                contentView = (UserControl)Page.LoadControl(pagePath);
                phdContent.Controls.Add(contentView);
            }
            catch (Exception ex)
            {
                Write2Log.WriteLogs("default.aspx", "GetPageName", ex.Message + "/" + cid + "/" + cidsub + "/" + id);
            }
        }
        /// <summary>
        /// UpLoad image
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnUploadImage_Click(object sender, EventArgs e)
        {
            try
            {
                if (fuImage.HasFile)
                {
                    string extendFile = Path.GetExtension(fuImage.FileName).ToLower();

                    if (extendFile == ".pdf")
                    {
                        string fileName = string.Format("{0}{1}{2}", fuImage.PostedFile.FileName.Split('.')[0], DateTime.Now.ToString("ddMMyyyyhhmmss"), extendFile);
                        filenameUpload = fileName;//string.Format("{0}.{1}", GenerateString.Generate(10), fuImage.FileName.Split('.')[1]);
                        string path = Path.Combine(Server.MapPath(ConfigurationManager.AppSettings["ProductUpload"]), filenameUpload);

                        fuImage.SaveAs(path);

                        //fuImage.SaveAs(path);
                        SetVisibleImg(false, string.Format("{0}/{1}", ConfigurationManager.AppSettings["ProductUpload"], filenameUpload));
                    }
                    else if (extendFile == ".mp3")
                    {
                        filenameUpload = UploadMp3(fuImage);
                        SetVisibleImg(false, filenameUpload);
                    }
                }
            }
            catch (Exception ex)
            {
                Write2Log.WriteLogs("admin_editproduct", "btnUploadImage_Click", ex.ToString());
            }
        }
Ejemplo n.º 19
0
        private void GetProduct()
        {
            try
            {
                //string categoryID = null;
                //categoryID = GetProductCategory();

                ProductBLL          pcBll = new ProductBLL();
                IList <PNK_Product> lst   = null;
                if (cid != string.Empty)
                {
                    lst = pcBll.GetListSearch(LangInt, cid, "1", string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, currentPageIndex, DBConvert.ParseInt(ConfigurationManager.AppSettings["pageSizeCate"]), out total);
                }


                if (total > 0)
                {
                    block_categorytemplate.lstSearch   = lst;
                    block_categorytemplate.TotalSearch = total;
                    //this.records = DBConvert.ParseString(total);
                    //this.pager.PageSize = DBConvert.ParseInt(ConfigurationManager.AppSettings["pageSizeCate"]);
                    //this.pager.ItemCount = total;

                    //this.rptResult.DataSource = lst;
                    //this.rptResult.DataBind();
                }
            }
            catch (Exception ex)
            {
                Write2Log.WriteLogs("block_category", "GetProduct", ex.Message);
            }
        }
Ejemplo n.º 20
0
        public void Update(T obj, List <TDesc> lst, string[] primaryKeyNames)
        {
            IFactory factory = DBHelper.CreateFactory();

            factory.BeginTransaction();
            try
            {
                dal.UpdateWithTransaction(obj, obj, primaryKeyNames, factory);
                string[] fields = { "MainId", "LangId" };
                foreach (var item in lst)
                {
                    dalDesc.UpdateWithTransaction(item, item, fields, factory);
                }
                factory.Commit();
            }
            catch (Exception ex)
            {
                Write2Log.WriteLogs("Generic2C<T, TDesc>", string.Format("Update({0} obj, List<TDesc> lst, string[] primaryKeyNames)", obj.GetType().Name), ex.Message);
                factory.Rollback();
            }
            finally
            {
                factory.Release();
            }
        }
Ejemplo n.º 21
0
        private void GetProduct()
        {
            try
            {
                string categoryID = null;
                categoryID = GetProductCategory();
                total      = 0;
                ProductBLL          pcBll = new ProductBLL();
                IList <PNK_Product> lst   = null;

                DataTable dtb   = DBHelper.ExcuteFromCmd("SELECT * FROM dbo.fc_GetAllChildProductCategory(" + categoryID + ",1)", null);
                string[]  array = dtb.AsEnumerable()
                                  .Select(row => row.Field <Int32>("id").ToString())
                                  .ToArray();
                string idFirst = string.Join(",", array);

                //Lọc sản phẩm trang chủ
                lst = pcBll.GetList(LangInt, string.Empty, "1", idFirst, string.Empty, currentPageIndex, DBConvert.ParseInt(ConfigurationManager.AppSettings["pageSizeCate"]), out total);
                if (lst.Count > 0)
                {
                    this.records              = DBConvert.ParseString(total);
                    this.pager.PageSize       = DBConvert.ParseInt(ConfigurationManager.AppSettings["pageSizeCate"]);
                    this.pager.ItemCount      = total;
                    this.rptResult.DataSource = lst;
                    this.rptResult.DataBind();
                }
            }
            catch (Exception ex)
            {
                Write2Log.WriteLogs("block_category", "GetProduct", ex.Message);
            }
        }
Ejemplo n.º 22
0
        public string POSTRequest(string URL, string postData)
        {
            string responseData = "", orderID = string.Empty, orderIDEncry = string.Empty, sessionID = string.Empty;

            try
            {
                HttpWebRequest hwrequest = (HttpWebRequest)WebRequest.Create(URL);
                hwrequest.Timeout   = 60000;
                hwrequest.Method    = "POST";
                hwrequest.KeepAlive = false;

                hwrequest.ContentType = "application/x-www-form-urlencoded";

                UTF8Encoding encoding      = new UTF8Encoding();
                byte[]       postByteArray = encoding.GetBytes(postData);
                hwrequest.ContentLength = postByteArray.Length;
                Stream postStream = hwrequest.GetRequestStream();
                postStream.Write(postByteArray, 0, postByteArray.Length);
                postStream.Close();


                // Attempt to receive the WebResponse to the WebRequest.
                using (HttpWebResponse hwresponse = (HttpWebResponse)hwrequest.GetResponse())
                {
                    if (hwresponse != null)
                    { // If we have valid WebResponse then read it.
                        using (StreamReader reader = new StreamReader(hwresponse.GetResponseStream()))
                        {
                            XPathDocument     doc   = new XPathDocument(reader);
                            XPathNavigator    xml   = doc.CreateNavigator();
                            XPathNodeIterator nodes = xml.Select("/TKKPG/Response/Order/row/OrderParams/row");
                            foreach (XPathNavigator item in nodes)
                            {
                                //responseData = item.Value;
                                string sPARAMNAME = item.SelectSingleNode("PARAMNAME").Value;
                                string sVal       = item.SelectSingleNode("VAL").Value;
                                if (sPARAMNAME.Equals("TWOResponseCode"))
                                {
                                    responseData = sVal;
                                }
                            }
                            reader.Close();
                        }
                    }

                    hwresponse.Close();
                }
            }
            catch (Exception ex)
            {
                Write2Log.WriteLogs("block_booking", "POSTRequest", ex.Message);
            }

            return(responseData);
        }
Ejemplo n.º 23
0
        private void GetProduct()
        {
            try
            {
                ProductBLL          pcBll = new ProductBLL();
                IList <PNK_Product> lst2 = null, lst3 = null;

                //Loại bỏ dấu ? để lấy link đúng
                string url = Request.RawUrl.Split('?')[0];

                //Cắt url, để lấy product name
                string[] urlArr = url.Split('/').ToArray();
                Array.Reverse(urlArr);
                lastUrl    = urlArr[0];
                forwardUrl = urlArr[1];

                switch (level)
                {
                case "1":
                    lst2 = pcBll.GetList(LangInt, pageName, string.Empty, string.Empty, string.Empty, null, string.Empty, 1, 9999, out total);
                    break;

                case "2":
                    lst2 = pcBll.GetList(LangInt, cid, string.Empty, string.Empty, string.Empty, null, string.Empty, 1, 9999, out total);

                    GetListImage(lst2[0].Id.ToString(), rptImg);
                    ltrHeader.Text         = lst2[0].ProductDesc.Title;
                    ltrHeaderCategory.Text = Common.UtilityLocal.ImagePathByFont(lst2[0], Request);
                    break;

                case "3":
                default:
                    lst2 = pcBll.GetList(LangInt, cid, string.Empty, string.Empty, string.Empty, null, string.Empty, 1, 9999, out total);
                    lst3 = lst2.Where(m => m.ProductDesc.TitleUrl == lastUrl).ToList();

                    GetListImage(lst3[0].Id.ToString(), rptImg);
                    ltrHeader.Text         = lst3[0].ProductDesc.Title;
                    ltrHeaderCategory.Text = Common.UtilityLocal.ImagePathByFont(lst3[0], Request);
                    break;
                }

                if (lst2.Count > 0)
                {
                    this.records              = DBConvert.ParseString(total);
                    this.pager.PageSize       = DBConvert.ParseInt(ConfigurationManager.AppSettings["pageSizeCate"]);
                    this.pager.ItemCount      = total;
                    this.rptResult.DataSource = lst2;
                    this.rptResult.DataBind();
                }
            }
            catch (Exception ex)
            {
                Write2Log.WriteLogs("block_category", "GetProduct", ex.Message);
            }
        }
Ejemplo n.º 24
0
        private void GetProduct()
        {
            try
            {
                string categoryID = null;
                categoryID = GetProductCategory();

                ProductBLL          pcBll = new ProductBLL();
                IList <PNK_Product> lst2  = null;
                IList <PNK_Product> lst3  = null;
                string level = string.Empty;

                if (Session["level"] != null)
                {
                    level = Session["level"].ToString();
                    switch (level)
                    {
                    case "1":
                        lst2 = pcBll.GetList(LangInt, pageName, string.Empty, string.Empty, string.Empty, null, string.Empty, 1, 9999, out total);
                        break;

                    case "2":
                        lst2 = pcBll.GetList(LangInt, cid, string.Empty, string.Empty, string.Empty, null, string.Empty, 1, 9999, out total);
                        GetListImage(lst2[0].Id.ToString(), rptImg);

                        ltrHeader.Text = lst2[0].ProductDesc.Title;
                        break;

                    case "3":
                    default:
                        lst2 = pcBll.GetList(LangInt, cid, string.Empty, string.Empty, string.Empty, null, string.Empty, 1, 9999, out total);
                        lst3 = lst2.Where(m => m.ProductDesc.TitleUrl == id).ToList();
                        GetListImage(lst3[0].Id.ToString(), rptImg);

                        ltrHeader.Text = lst3[0].ProductDesc.Title;
                        break;
                    }
                }

                if (total > 0)
                {
                    this.records         = DBConvert.ParseString(total);
                    this.pager.PageSize  = DBConvert.ParseInt(ConfigurationManager.AppSettings["pageSizeCate"]);
                    this.pager.ItemCount = total;

                    this.rptResult.DataSource = lst2;
                    this.rptResult.DataBind();
                }
            }
            catch (Exception ex)
            {
                Write2Log.WriteLogs("block_category", "GetProduct", ex.Message);
            }
        }
Ejemplo n.º 25
0
        public static bool CheckValidUsername(string username)
        {
            IFactory factory = DBHelper.CreateFactory();
            bool     re      = false;

            try
            {
                string prefix = string.Empty;
                switch (ConfigurationManager.AppSettings["Database"])
                {
                case "SQLServer":
                    prefix = "@";
                    break;

                case "MySQL":
                    prefix = "v_";
                    break;
                }

                DbCommand        cmd  = factory.MakeCommandFromStore("CheckValidUSer");
                IDbDataParameter para = cmd.CreateParameter();
                para.ParameterName = string.Format("{0}Username", prefix);
                para.DbType        = DbType.String;
                para.Value         = username;
                cmd.Parameters.Add(para);

                para = cmd.CreateParameter();
                para.ParameterName = "@total";
                para.DbType        = DbType.Int32;
                para.Direction     = ParameterDirection.Output;
                cmd.Parameters.Add(para);

                cmd.ExecuteNonQuery();
                int strTemp = DBConvert.ParseInt(cmd.Parameters["@total"].Value.ToString());
                if (strTemp == 1)
                {
                    re = false;
                }
                else if (strTemp == 0)
                {
                    re = true;
                }
            }
            catch (Exception ex)
            {
                Write2Log.WriteLogs("UserBLL", "CheckValidUsername", ex.ToString());
            }
            finally
            {
                factory.Release();
            }

            return(re);
        }
Ejemplo n.º 26
0
 private void GetPageName(string pageName)
 {
     try
     {
         pageName = configXML.LoadPage(pageName, Constant.DSC.IdXmlPageAdmin, id);
         UserControl contentView = (UserControl)Page.LoadControl(pageName);
         phdContent.Controls.Add(contentView);
     }
     catch (Exception ex)
     {
         Write2Log.WriteLogs("GetPageName", "Admin default", ex.Message);
     }
 }
Ejemplo n.º 27
0
        private void GetVideo()
        {
            try
            {
                string categoryID = GetProductCategory();

                ProductBLL          pcBll = new ProductBLL();
                IList <PNK_Product> lst2  = null;
                IList <PNK_Product> lst3  = null;
                string level = string.Empty;

                if (Session["level"] != null)
                {
                    level = Session["level"].ToString();
                    switch (level)
                    {
                    case "1":
                        lst2 = pcBll.GetList(LangInt, pageName, string.Empty, string.Empty, string.Empty, null, string.Empty, 1, 9999, out total);
                        break;

                    case "2":
                        lst2 = pcBll.GetList(LangInt, cid, string.Empty, string.Empty, string.Empty, null, string.Empty, 1, 9999, out total);
                        ifrTop.Attributes.Add("src", "//www.youtube.com/embed/" + UtilityLocal.GetVideoList(lst2[0].Id) + "?rel=0&amp;autoplay=0");
                        break;

                    case "3":
                    default:
                        lst2 = pcBll.GetList(LangInt, cid, string.Empty, string.Empty, string.Empty, null, string.Empty, 1, 9999, out total);
                        lst3 = lst2.Where(m => m.ProductDesc.TitleUrl == id).ToList();
                        ifrTop.Attributes.Add("src", "//www.youtube.com/embed/" + UtilityLocal.GetVideoList(lst3[0].Id) + "?rel=0&amp;autoplay=0");


                        break;
                    }
                }

                if (total > 0)
                {
                    this.records         = DBConvert.ParseString(total);
                    this.pager.PageSize  = DBConvert.ParseInt(ConfigurationManager.AppSettings["pageSizeCate"]);
                    this.pager.ItemCount = total;

                    this.rptVideo.DataSource = lst2;
                    this.rptVideo.DataBind();
                }
            }
            catch (Exception ex)
            {
                Write2Log.WriteLogs("GetVideo", "GetVideo", ex.Message);
            }
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Sử dụng host email để send email
        /// </summary>
        /// <param name="subject"></param>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <param name="header"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        public static bool SendEmailAndAttach(string subject, string from, string header, string body, string filePathAttach)
        {
            bool result = false;

            MailMessage mail = new MailMessage();

            mail.From = new MailAddress(ConfigurationManager.AppSettings["MailTo"]);
            mail.To.Add(ConfigurationManager.AppSettings["MailTo"]);
            mail.Subject      = subject;
            mail.IsBodyHtml   = true;
            mail.Body         = body;
            mail.BodyEncoding = Encoding.UTF8;

            MailAddress copy = new MailAddress(from);

            mail.CC.Add(copy);

            //Configure an SmtpClient to send the mail.
            SmtpClient client = new SmtpClient();

            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            client.EnableSsl      = DBConvert.ParseBool(ConfigurationManager.AppSettings["EnableSsl"]);
            client.Host           = ConfigurationManager.AppSettings["SmtpServer"];
            client.Port           = DBConvert.ParseInt(ConfigurationManager.AppSettings["Port"]);

            //Attach file
            System.Net.Mail.Attachment attachment;
            attachment = new System.Net.Mail.Attachment(filePathAttach);
            mail.Attachments.Add(attachment);

            NetworkCredential credentials = new NetworkCredential(ConfigurationManager.AppSettings["UserMail"], ConfigurationManager.AppSettings["PassMail"]);

            client.UseDefaultCredentials = false;
            client.Credentials           = credentials;

            try
            {
                //Send the msg
                client.Send(mail);
                result = true;
            }
            catch (Exception ex)
            {
                result = false;
                Write2Log.WriteLogs(ConfigurationManager.AppSettings["UserMail"] + "1", ConfigurationManager.AppSettings["PassMail"], ex.ToString());
            }
            return(result);
        }
Ejemplo n.º 29
0
 protected void btnUploadLocation_Click(object sender, EventArgs e)
 {
     try
     {
         if (fuLocation.HasFile)
         {
             filenameUploadLocation = string.Format("{0}.{1}", DateTime.Now.Ticks + GenerateString.Generate(5), fuLocation.FileName.Split('.')[1]);
             fuLocation.SaveAs(Path.Combine(Server.MapPath(ConfigurationManager.AppSettings["LogoUpload"]), filenameUploadLocation));
             SetVisibleImg(false, string.Format("{0}/{1}", ConfigurationManager.AppSettings["LogoUpload"], filenameUploadLocation), fuLocation, btnUploadLocation, lbnViewLocation, lbnDeleteLocation);
         }
     }
     catch (Exception ex)
     {
         Write2Log.WriteLogs("admin_editnews", "btnUploadLocation_Click", ex.ToString());
     }
 }
Ejemplo n.º 30
0
        /// <summary>
        /// get data for insert update
        /// </summary>
        /// <param name="userObj"></param>
        /// <returns></returns>
        private PNK_ProductCategory GetDataObjectParent(PNK_ProductCategory productcatObj)
        {
            try
            {
                productcatObj.Published      = chkPublished.Checked ? "1" : "0";
                productcatObj.Ordering       = DBConvert.ParseInt(txtOrder.Value);
                productcatObj.UpdateDate     = DateTime.Now;
                productcatObj.ParentId       = DBConvert.ParseInt(drpCategory.SelectedValue);
                productcatObj.SmallImage     = chkMenuFooter.Checked ? "1" : "0";
                productcatObj.ThumbnailImage = ViewState["attributeId"] == null ? string.Empty : ViewState["attributeId"].ToString();
                productcatObj.Page           = drpPage.SelectedValue;
                productcatObj.PageDetail     = drpPageDetail.SelectedValue;

                #region Get image

                HtmlControl txtFontName = block_baseimage.FindControl("txtFontName") as HtmlControl;
                productcatObj.ImageFont = string.IsNullOrEmpty(txtFontName.Attributes["value"]) == true ? string.Empty : txtFontName.Attributes["value"];

                HtmlControl rdImageFont = block_baseimage.FindControl("rdImageFont") as HtmlControl;
                if (rdImageFont != null && rdImageFont.Attributes["checked"] == "checked")
                {
                    productcatObj.ImageType = DBConvert.ParseInt(rdImageFont.Attributes["value"]);
                }
                else
                {
                    productcatObj.ImageType = 1;
                }

                HtmlControl hddImageName = block_baseimage.FindControl("hddImageName") as HtmlControl;
                if (hddImageName != null && hddImageName.Attributes["value"] != null)
                {
                    productcatObj.BaseImage = hddImageName.Attributes["value"].ToString();
                }
                else
                {
                    productcatObj.BaseImage = "";
                }

                #endregion
            }
            catch (Exception ex)
            {
                Write2Log.WriteLogs("GetDataObjectParent", "admin_editproductcategory", ex.Message);
            }
            return(productcatObj);
        }