private void SaveMemoBySubArea()
        {
            GeneralMemoConcessionDetailManager GMCDM = new GeneralMemoConcessionDetailManager();
            PricePointManager PPM = new PricePointManager();
            IRMS.Entities.GeneralMemoConcession genMemoObj = new IRMS.Entities.GeneralMemoConcession();

            SubGroupAreaManager _SubGroupAreaManager = new SubGroupAreaManager();
            List<SubGroupAreaClass> _SubGroupAreaList = new List<SubGroupAreaClass>();

            genMemoObj.MemoDate = new IRMS.BusinessLogic.DataAccess.ISERVELibrary().GetServerDate();

            genMemoObj.Header = txtMemoHeader.Text;
            genMemoObj.Intro = txtIntroduction.Text;
            genMemoObj.BrandName = DDLBrand.SelectedItem.Text;

            genMemoObj.GroupNumber = Convert.ToInt32(DDLAreaGroup.SelectedItem.Value);
            genMemoObj.PriceType = rdioApplyPricePointTo.SelectedValue.ToUpperInvariant();

            genMemoObj.FromDate = new IRMS.BusinessLogic.DataAccess.ISERVELibrary().GetServerDate();
            genMemoObj.ToDate = Convert.ToDateTime(txtPromoPeriodTo.Text);
            genMemoObj.Message = txtMessage.Text;
            genMemoObj.Footer = txtFooter.Text;
            //genMemoObj.Status = rdioStatus.SelectedValue;
            genMemoObj.Status = "Pending";
            genMemoObj.Remark = txtRemarks.Text;

            genMemoObj.MemoNumber = txtMemoNo.Text;
            GMCM.Save(ref genMemoObj, true);
            SaveGenMemoDetail(genMemoObj);
            SavePricePointBySubArea(genMemoObj);
            txtMemoNo.Text = genMemoObj.MemoNumber;
        }
        protected void gvItems_SelectedIndexChangedEx(object sender, EventArgs e)
        {
            _GenMemoObj = (IRMS.Entities.GeneralMemoConcession)Session["GenMemoObject"];
            PriceManager pM = new PriceManager();
            PricePointManager ppM = new PricePointManager();

            dtMarkdownList = (DataTable)Session["LIST"]; ;
            var ItemFoundResult = (from myRow in dtMarkdownList.AsEnumerable()
                                   where myRow.Field<string>("STYLE #") == gvItems.SelectedRow.Cells[1].Text
                                   select myRow);

            if (ItemFoundResult.Count() > 0)
            {
                this.lblDuplicateCount.Text = "{0} items found!";
                lblDuplicateCount.Text = string.Format(lblDuplicateCount.Text, 1);
                hfDuplicateStylePopupExtender.Show();
                return;
            }

            Double dResult = 0;
            //GET REGULAR PRICE
            dResult = Convert.ToDouble(pM.GetSRPByStyle(gvItems.SelectedRow.Cells[1].Text, txtBrandName.Text).Price_2);
            lblPriceStatus.Text = "NEW";

            //GET MARKDOWN PRICE IF ANY
            PricePoint pPoint = new PricePoint();

            int GroupNo = -1;

            GroupNo = _GenMemoObj.GroupNumber;
            if (_GenMemoObj.PriceType == "AREA")
            {
                if (GroupNo == 0)
                    GroupNo = 1;
                else
                {
                    if (GroupNo == 99)
                        GroupNo = 2;
                }
            }

            pPoint = ppM.GetStyleCurrentPrice1(gvItems.SelectedRow.Cells[1].Text, txtBrandName.Text, _GenMemoObj.PriceType, GroupNo);

            //GET MARKDOWN PRICE IF ANY
            if (pPoint != null)
            {
                dResult = Convert.ToDouble(pPoint.Price);
                lblPriceStatus.Text = "MARKDOWN";
            }

            txtCurrentPrice.Text = string.Format("{0:0.00}", dResult);
            btnAddNewItem_ModalPopupExtender.Show();
        }
        private void LoadMDMemoInfo()
        {
            GroupAreaMemoManager gAMM = new GroupAreaMemoManager();
            PricePointManager ppM = new PricePointManager();

            _GenMemoObj = GMCM.GetGeneralMemoConcessionByKey(Convert.ToInt64(Session["MemoID"]));
            _GenMemoObj.RecordNumber = Convert.ToInt32(Session["MemoID"]);
            Session["GenMemoObject"] = _GenMemoObj;

            txtMemoNumber.Text = _GenMemoObj.MemoNumber;
            txtMemoDate.Text = _GenMemoObj.MemoDate.ToShortDateString();
            txtBrandName.Text = _GenMemoObj.BrandName;

            txtApplyPricePoint.Text = _GenMemoObj.PriceType;
            txtEffectivityDate.Text = _GenMemoObj.FromDate.ToShortDateString();

            if (_GenMemoObj.PriceType.ToUpper() == "AREA")
            {
                pnlAreaGroup.Visible = true;
                pnlSubAreaGroup.Visible = false;
                mvApplyPricePoint.SetActiveView(vAreaGroup);
                lblSubArea.Visible = false;
                txtSubAreaGroup.Visible = false;
                txtAreaGroup.Text = gAMM.GetAreaGroupMemoByKey(_GenMemoObj.GroupNumber).GroupName.ToUpper();
            }
            else if (_GenMemoObj.PriceType.ToUpper() == "SUB-AREA")
            {
                pnlSubAreaGroup.Visible = true;
                pnlAreaGroup.Visible = false;
                //lblSubArea.Visible = true;
                mvApplyPricePoint.SetActiveView(vAreaGroup);
                lblSubArea.Visible = true;
                txtSubAreaGroup.Visible = true;
                txtAreaGroup.Text = gAMM.GetAreaGroupMemoByKey(_GenMemoObj.GroupNumber).GroupName.ToUpper();
                List<int> GroupNoList = ppM.GetDistinctGroupNoByMemoNo(_GenMemoObj.MemoNumber);

                if (GroupNoList.Count > 1)
                    txtSubAreaGroup.Text = "ALL";
                else
                    txtSubAreaGroup.Text = new SubGroupAreaManager().GetSubGroupArea(GroupNoList[0]).GroupName.ToUpper();

                txtPromoPeriodTo.Text = _GenMemoObj.ToDate.ToShortDateString();
            }
            else
            {
                mvApplyPricePoint.SetActiveView(vCustomer);
            }

            switch (_GenMemoObj.GroupNumber)
            {
                case 0:
                    {
                        txtAreaGroup.Text = "ALL";
                    }
                    break;
                case 99:
                    {
                        txtAreaGroup.Text = "ALL PROVINCES";
                    }
                    break;
            }
            LoadMDMemoList();
        }
        protected void btnUpdateGeneralMemo_ClickEx(object sender, EventArgs e)
        {
            DateTime ApprovedDate;
            _GenMemoObj = GMCM.GetGeneralMemoConcessionByKey(Convert.ToInt64(Session["MemoID"]));

            PricePointManager PPM = new PricePointManager();
            ApprovedDate = PPM.GetApprovedDate(_GenMemoObj.MemoNumber);

            PPM.DeleteByMemoNo(_GenMemoObj.MemoNumber);

            GeneralMemoConcessionDetailManager GMCDManager = new GeneralMemoConcessionDetailManager();
            GMCDManager.DeleteByMemoID(_GenMemoObj.RecordNumber);

             if (_GenMemoObj.PriceType.ToUpper() == "AREA")
                SavePricePointByArea(_GenMemoObj,ApprovedDate);

            if (_GenMemoObj.PriceType.ToUpper() == "SUB-AREA")
                SavePricePointBySubArea(_GenMemoObj,ApprovedDate);

            if (_GenMemoObj.PriceType.ToUpper() == "CUSTOMER")
                SavePricePointByCustomer(_GenMemoObj,ApprovedDate);

            SaveGenMemoDetail(_GenMemoObj);

            lblNewMemoNo.Text = string.Format(lblNewMemoNo.Text, txtMemoNumber.Text);
            hfMemoNoPopupExtender.Show();
        }