Пример #1
0
    private void SetBannersInXML()
    {
        try
        {
            Banner      objB           = new Banner();
            BannerOrder objBannerOrder = new BannerOrder();
            PageId = Convert.ToInt32(ddlPage.SelectedValue);
            UserID = Convert.ToInt32(ddlUserType.SelectedValue);
            string PageName          = string.Empty;
            string virtualpath2      = string.Empty;
            string virtualmobilepath = string.Empty;
            string ImageName2        = string.Empty;
            string BannerId          = string.Empty;
            string PgName            = string.Empty;
            string IsCoupon          = string.Empty;
            int    boolIscoupon      = 0;
            string strPgName         = GetPageNameForSequence(Convert.ToString(PageId), Convert.ToString(UserID));
            DeleteFromXml(strPgName, PageId, UserID);
            DataTable OrderDt = (DataTable)ViewState["myDt"];
            foreach (DataListItem item in dtlOrder.Items)
            {
                TextBox  myTextBox   = (TextBox)item.FindControl("txtId");
                Label    lblPageName = (Label)item.FindControl("lblPageName");
                Label    lblIsCoupon = (Label)item.FindControl("lblIsCoupon");
                Label    lblId       = (Label)item.FindControl("lblId");
                CheckBox chkIsCOupon = (CheckBox)item.FindControl("chkIsCOupon");
                if (chkIsCOupon.Checked)
                {
                    boolIscoupon = 1;
                }
                else
                {
                    boolIscoupon = 0;
                }

                BannerId = myTextBox.Text;
                PgName   = strPgName;
                IsCoupon = lblIsCoupon.Text;
                int Id = Convert.ToInt32(lblId.Text);
                if (BannerId != "")
                {
                    for (int i = 0; i < OrderDt.Rows.Count; i++)
                    {
                        DataRow row = OrderDt.Rows[i];
                        if (BannerId == Convert.ToString(row["BId"]))
                        {
                            virtualpath2      = Convert.ToString(row["BannerPath"]);
                            ImageName2        = Convert.ToString(row["BannerName"]);
                            virtualmobilepath = Convert.ToString(row["virtualmobilepath"]);
                            objBannerOrder.UpdateBannerSequence(Id, Convert.ToInt32(BannerId), boolIscoupon);
                            if (PageId != 12)
                            {
                                AddBannerToXml(virtualpath2, ImageName2, IsCoupon, strPgName, Convert.ToString(PageId), Convert.ToString(UserID), virtualmobilepath, BannerId);
                            }
                            break;
                        }
                        else
                        {
                            objBannerOrder.UpdateBannerSequence(Id, 0, 0);
                        }
                    }
                }
                else
                {
                    objBannerOrder.UpdateBannerSequence(Id, 0, 0);
                }
            }
            DataSet dsDefault = new DataSet();
            int     emtCnt    = 0;
            int     EID       = 0;
            DataSet dsPages   = new DataSet();
            dsPages = objBannerOrder.GetPagesNames();
            for (int j = 0; j < dsPages.Tables[0].Rows.Count; j++)
            {
                DataRow PageRow = dsPages.Tables[0].Rows[j];
                PageId    = Convert.ToInt32(PageRow["PageId"]);
                UserID    = Convert.ToInt32(PageRow["UserId"]);
                strPgName = GetPageNameForSequence(Convert.ToString(PageId), Convert.ToString(UserID));
                dsDefault = objBannerOrder.GetBannerList(PageId, UserID);
                if (dsDefault.Tables[1].Rows.Count > 0)
                {
                    DataRow countRow = dsDefault.Tables[1].Rows[0];

                    if (dsDefault.Tables[4].Rows.Count > 0)
                    {
                        DataRow checkDefRow = dsDefault.Tables[4].Rows[0];
                        if (Convert.ToInt32(checkDefRow["defbannercount"]) == 0)
                        {
                            if (Convert.ToInt32(countRow["bannercount"]) == 0)
                            {
                                DeleteFromXml(strPgName, PageId, UserID);
                                objBannerOrder.UpdateBannerSequenceByPage(strPgName);
                            }
                        }
                    }


                    if (Convert.ToString(countRow["bannercount"]) == "0")
                    {
                        DeleteFromXml(strPgName, PageId, UserID);
                        emtCnt = dsDefault.Tables[0].Rows.Count;
                        int Kcount = dsDefault.Tables[2].Rows.Count;
                        for (int k = 0; k < dsDefault.Tables[2].Rows.Count; k++)
                        {
                            DataRow BannerRow = dsDefault.Tables[2].Rows[k];

                            if (emtCnt <= Kcount)
                            {
                                DataRow emptyRow = dsDefault.Tables[0].Rows[k];
                                EID = Convert.ToInt32(emptyRow["ID"]);
                            }

                            BannerId     = Convert.ToString(BannerRow["BannerId"]);
                            boolIscoupon = Convert.ToInt32(BannerRow["IsCoupon"]);
                            for (int i = 0; i < OrderDt.Rows.Count; i++)
                            {
                                DataRow defaultRow = OrderDt.Rows[i];

                                if (BannerId == Convert.ToString(defaultRow["BId"]))
                                {
                                    virtualpath2 = Convert.ToString(defaultRow["BannerPath"]);
                                    ImageName2   = Convert.ToString(defaultRow["BannerName"]);
                                    objBannerOrder.UpdateBannerSequence(EID, Convert.ToInt32(BannerId), boolIscoupon);
                                    AddBannerToXml(virtualpath2, ImageName2, IsCoupon, strPgName, Convert.ToString(PageId), Convert.ToString(UserID), virtualmobilepath, BannerId);
                                }
                            }
                        }
                    }
                }
            }

            BindData();
            BindSequenceData();
        }
        catch { }
    }
Пример #2
0
    protected void ManageBannerSequence()
    {
        try
        {
            Banner      objB           = new Banner();
            BannerOrder objBannerOrder = new BannerOrder();
            PageId = Convert.ToInt32(ddlPage.SelectedValue);
            string PageName          = string.Empty;
            string virtualpath2      = string.Empty;
            string virtualmobilepath = string.Empty;
            string ImageName2        = string.Empty;
            string BannerId          = string.Empty;
            string PgName            = string.Empty;
            string IsCoupon          = string.Empty;
            int    boolIscoupon      = 0;
            int    uId = 0;
            for (int tempuid = 0; tempuid < 4; tempuid++)
            {
                if (uId == 0)
                {
                    UserID = 0;
                }
                else
                {
                    uId++;
                    UserID = uId;
                }
                string    strPgName = GetPageNameForSequence(Convert.ToString(PageId), Convert.ToString(UserID));
                DataTable OrderDt   = (DataTable)ViewState["myDt"];
                foreach (DataListItem item in dtlOrder.Items)
                {
                    TextBox  myTextBox   = (TextBox)item.FindControl("txtId");
                    Label    lblPageName = (Label)item.FindControl("lblPageName");
                    Label    lblIsCoupon = (Label)item.FindControl("lblIsCoupon");
                    Label    lblId       = (Label)item.FindControl("lblId");
                    CheckBox chkIsCOupon = (CheckBox)item.FindControl("chkIsCOupon");

                    int MaxB = 0;
                    MaxB     = objB.GetMaxBannerId();
                    BannerId = Convert.ToString(MaxB);
                    IsCoupon = Convert.ToBoolean(false).ToString();
                    int Id = Convert.ToInt32(lblId.Text);
                    if (BannerId != "")
                    {
                        for (int i = 0; i < OrderDt.Rows.Count; i++)
                        {
                            DataRow row = OrderDt.Rows[i];
                            if (BannerId == Convert.ToString(row["BId"]))
                            {
                                virtualpath2      = Convert.ToString(row["BannerPath"]);
                                ImageName2        = Convert.ToString(row["BannerName"]);
                                virtualmobilepath = Convert.ToString(row["virtualmobilepath"]);
                                objBannerOrder.UpdateBannerSequence(Id, Convert.ToInt32(BannerId), boolIscoupon);
                                if (PageId != 10)
                                {
                                    AddBannerToXml(virtualpath2, ImageName2, IsCoupon, strPgName, Convert.ToString(PageId), Convert.ToString(UserID), virtualmobilepath, BannerId);
                                }
                                break;
                            }
                            else
                            {
                                objBannerOrder.UpdateBannerSequence(Id, 0, 0);
                            }
                        }
                    }
                    else
                    {
                        objBannerOrder.UpdateBannerSequence(Id, 0, 0);
                    }
                }
            }
        }
        catch (Exception ex)
        {
            ErrMessage(ex.Message.ToString());
        }
    }