Ejemplo n.º 1
0
        public static ResultBOL <int> InsertOrUpdate(OtherBOL BOL)
        {
            string stored = "sp_Other_Insert_Update";
            var    result = DataAccessHelpers.ExecuteStored(stored, BOL.GetParameters());

            return(result);
        }
Ejemplo n.º 2
0
        private void UpdateOtherProcess()
        {
            OtherBOL other = new OtherBOL()
            {
                Id             = string.IsNullOrEmpty(hfId.Value) ? 0 : int.Parse(hfId.Value),
                Name_VN        = tbxNameVN.Text,
                Name_EN        = tbxNameEN.Text,
                Description_VN = tbxDesVN.Text,
                Description_EN = tbxDesEN.Text,
                IsGroup        = true,
                InsertDate     = DateTime.Now,
                UpdatedDate    = DateTime.Now
            };

            var result = OtherDAL.InsertOrUpdate(other);

            if (result.Code < 0)
            {
                lbError.InnerText = result.ErrorMessage;
                lbError.Visible   = true;

                return;
            }

            StartClearData();

            Response.Redirect(Request.RawUrl, false);
        }
Ejemplo n.º 3
0
        private void StartLoadSubOtherInfo(int id)
        {
            string tag = __tag + "[StartLoadSubOtherInfo]";

            LogHelpers.WriteStatus(tag, "Start...");

            lbError.Visible = false;

            try
            {
                var result = OtherDAL.Get(id);
                if (result.Code < 0)
                {
                    lbError.InnerText = result.ErrorMessage;
                    lbError.Visible   = true;

                    return;
                }

                OtherBOL other = new OtherBOL(result.Data.Tables[0].Rows[0]);
                tbxNameVN.Text = other.Name_VN;
                tbxNameEN.Text = other.Name_EN;
                tbxLink.Text   = other.Link;
                if (!string.IsNullOrEmpty(other.ImageLink))
                {
                    //imgImage.ImageUrl = "~/" + Path.Combine(Utilities.GetDirectory("ImagesDir"), other.ImageLink.Split('|')[0]);
                    //imgImage.Visible = true;
                    //---
                    groupImages.Visible = true;
                    StartLoadImages(other.ImageLink);
                }
                else
                {
                    //imgImage.Visible = false;
                    groupImages.Visible = false;
                }
                tbxDesVN.Text = other.Description_VN;
                tbxDesEN.Text = other.Description_EN;

                btnSubmit.Text    = "Update";
                btnCancel.Visible = true;
            }
            catch (Exception ex)
            {
                LogHelpers.WriteException(tag, ex.ToString());

                lbError.InnerText = ex.Message;
                lbError.Visible   = true;
            }
            finally
            {
                LogHelpers.WriteStatus(tag, "End.");
            }
        }
Ejemplo n.º 4
0
        private void InsertOrUpdateBannerProcess()
        {
            string tag = __tag + "[InsertOrUpdateBannerProcess]";

            LogHelpers.WriteStatus(tag, "Start...");

            try
            {
                OtherBOL banner = new OtherBOL()
                {
                    Id             = _id > 0 ? _id : 0,
                    Name_VN        = tbxNameVN.Text,
                    Name_EN        = tbxNameEN.Text,
                    Description_VN = tbxDesVN.Text,
                    Description_EN = tbxDesEN.Text,
                    Link           = tbxLink.Text,
                    ImageLink      = UploadImageProcess(),
                    ParentId       = _catId,
                    OtherType      = _catId,
                    InsertDate     = DateTime.Now,
                    UpdatedDate    = DateTime.Now
                };

                var result = OtherDAL.InsertOrUpdate(banner);
                if (result.Code < 0)
                {
                    lbError.InnerText = result.ErrorMessage;
                    lbError.Visible   = true;

                    return;
                }

                StartClearData();

                Response.Redirect(Request.RawUrl, false);
            }
            catch (Exception ex)
            {
                LogHelpers.WriteException(tag, ex.ToString());

                lbError.InnerText = ex.Message;
                lbError.Visible   = true;
            }
            finally
            {
                LogHelpers.WriteStatus(tag, "End.");
            }
        }
Ejemplo n.º 5
0
        private void InsertOrUpdateBannerProcess()
        {
            string tag = __tag + "[InsertOrUpdateBannerProcess]";

            LogHelpers.WriteStatus(tag, "Start...");

            try
            {
                OtherBOL banner = new OtherBOL()
                {
                    Name_VN        = tbxNameVN.Text,
                    Name_EN        = tbxNameEN.Text,
                    Description_VN = tbxDesVN.Text,
                    Description_EN = tbxDesEN.Text,
                    Link           = tbxLink.Text,
                    ImageLink      = UploadImageProcess(),
                    InsertDate     = DateTime.Now,
                    UpdatedDate    = DateTime.Now
                };

                var result = OtherDAL.InsertOrUpdate(banner);
                if (result.Code < 0)
                {
                    lbError.InnerText = result.ErrorMessage;
                    lbError.Visible   = true;

                    return;
                }
            }
            catch (Exception ex)
            {
                LogHelpers.WriteException(tag, ex.ToString());

                lbError.InnerText = ex.Message;
                lbError.Visible   = true;
            }
            finally
            {
                LogHelpers.WriteStatus(tag, "End.");
            }
        }
Ejemplo n.º 6
0
        private void StartLoadOtherGroupInfo(int id)
        {
#if DEBUG
            _log.Debug("id: {0}", id);
#endif
            lbError.Visible = false;

            try
            {
                var result = OtherDAL.Get(id);
                if (result.Code < 0)
                {
                    lbError.InnerText = result.ErrorMessage;
                    lbError.Visible   = true;
                    return;
                }

                OtherBOL otherType = new OtherBOL(result.Data.Tables[0].Rows[0]);
                hfId.Value     = otherType.Id.ToString();
                tbxNameVN.Text = otherType.Name_VN;
                tbxNameEN.Text = otherType.Name_EN;
                tbxDesVN.Text  = otherType.Description_VN;
                tbxDesEN.Text  = otherType.Description_EN;

                tbxNameEN.Enabled = true;
                tbxNameVN.Enabled = true;
                //---
                //btnSubmit.Text = "Update";
                //btnCancel.Visible = true;
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
                lbError.InnerText = ex.Message;
                lbError.Visible   = true;
            }
        }
Ejemplo n.º 7
0
        public void ProcessRequest(HttpContext context)
        {
            var jsonString = string.Empty;

            context.Request.InputStream.Position = 0;

            try
            {
                var inputStream = new StreamReader(context.Request.InputStream);
                jsonString = inputStream.ReadToEnd();
                inputStream.Close();
                //--
                OtherBOL other = JsonConvert.DeserializeObject <OtherBOL>(jsonString);
                other.InsertDate  = DateTime.Now;
                other.UpdatedDate = DateTime.Now;
                other.IsGroup     = true;

                var result = OtherDAL.InsertOrUpdate(other);
                //---
                object obj = new
                {
                    Code    = result.Code,
                    Message = result.ErrorMessage,
                    Id      = result.DbReturnValue,
                    Name    = other.Name_VN
                };
                //---
                string responseString = JsonConvert.SerializeObject(obj);
                context.Response.ContentType = "application/json";
                context.Response.Write(responseString);
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
Ejemplo n.º 8
0
        private void StartAddMenuOther()
        {
            string tag = __tag + "[StartAddMenuOther]";

            LogHelpers.WriteStatus(tag, "Start...");

            try
            {
                HtmlGenericControl li = new HtmlGenericControl("li");
                li.InnerHtml = string.Format("<a href='{0}'>{1}</a>",
                                             "Other.aspx",
                                             "Other");

                var result = OtherTypeDAL.GetAll();
                if (result.Code >= 0 && result.Data.Tables.Count > 0)
                {
                    HtmlGenericControl ul = new HtmlGenericControl("ul");

                    foreach (DataRow row in result.Data.Tables[0].Rows)
                    {
                        OtherTypeBOL otherType = new OtherTypeBOL(row);
                        if (otherType == null)
                        {
                            continue;
                        }

                        HtmlGenericControl subLi = new HtmlGenericControl("li");
                        subLi.InnerHtml = string.Format("<a href='{0}?Id={1}'>{2}</a>",
                                                        "Other.aspx",
                                                        otherType.Id,
                                                        otherType.Name_VN);
                        //---
                        HtmlGenericControl subUl = null;
                        foreach (DataRow r in result.Data.Tables[1].Rows)
                        {
                            OtherBOL other = new OtherBOL(r);
                            if (other.ParentId == otherType.Id)
                            {
                                if (subUl == null)
                                {
                                    subUl = new HtmlGenericControl("ul");
                                }

                                HtmlGenericControl sLi = new HtmlGenericControl("li");
                                sLi.InnerHtml = string.Format("<a href='{0}?GroupId={1}'>{2}</a>",
                                                              "Other.aspx",
                                                              other.Id,
                                                              other.Name_VN);
                                subUl.Controls.Add(sLi);
                            }
                        }

                        if (subUl != null)
                        {
                            subLi.Controls.Add(subUl);
                        }

                        ul.Controls.Add(subLi);
                    }

                    if (ul.Controls.Count > 0)
                    {
                        li.Controls.Add(ul);
                    }
                }

                this.ulMenuAdmin.Controls.Add(li);
            }
            catch (Exception ex)
            {
                LogHelpers.WriteException(tag, ex.ToString());
            }
            finally
            {
                LogHelpers.WriteStatus(tag, "End.");
            }
        }
Ejemplo n.º 9
0
        private void StartBindingBanners()
        {
            string tag = __tag + "[StartBindingBanners]";

            LogHelpers.WriteStatus(tag, "Start...");

            try
            {
                var result = OtherDAL.GetAllBanners();
                if (result.Code < 0)
                {
                    return;
                }

                for (int i = 0; i < result.Data.Tables[0].Rows.Count; i++)
                {
                    OtherBOL other = new OtherBOL(result.Data.Tables[0].Rows[i]);
                    //----
                    HtmlGenericControl li = new HtmlGenericControl("li");
                    li.Attributes.Add("data-target", "#banner-carousel");
                    li.Attributes.Add("data-slide-to", i.ToString());
                    if (i == 0)
                    {
                        li.Attributes.Add("class", "active");
                    }

                    olbanners.Controls.Add(li);
                    //---
                    string imgUrl = Path.Combine(Utilities.GetDirectory("ImageOtherDir"), other.ImageLink);
                    //--
                    HtmlGenericControl divImage = new HtmlGenericControl("div");
                    if (i == 0)
                    {
                        divImage.Attributes.Add("class", "item active");
                    }
                    else
                    {
                        divImage.Attributes.Add("class", "item");
                    }
                    //---
                    HtmlGenericControl img = new HtmlGenericControl("img");
                    img.Attributes.Add("src", imgUrl);

                    HtmlGenericControl divBannerTitle = new HtmlGenericControl("div");
                    divBannerTitle.Attributes.Add("class", "banner-title");
                    HtmlGenericControl divBannerTitleBackground = new HtmlGenericControl("div");
                    divBannerTitleBackground.Attributes.Add("class", "banner-title-background");
                    HtmlGenericControl hplBanner = new HtmlGenericControl("a");
                    hplBanner.InnerText = other.Name_VN;
                    hplBanner.Attributes.Add("href", other.Link);

                    divBannerTitle.Controls.Add(divBannerTitleBackground);
                    divBannerTitle.Controls.Add(hplBanner);

                    divImage.Controls.Add(img);
                    divImage.Controls.Add(divBannerTitle);

                    BannerCarouselInner.Controls.Add(divImage);
                }
            }
            catch (Exception ex)
            {
                LogHelpers.WriteException(tag, ex.ToString());
            }
            finally
            {
                LogHelpers.WriteStatus(tag, "End.");
            }
        }