public void Save(PricePoint Object)
 {
     using (DbManager dbm = new DbManager())
     {
         Accessor.Query.Insert(dbm, Object);
     }
 }
        private void SavePricePointBySubArea(IRMS.Entities.GeneralMemoConcession genMemoObj)
        {
            PricePointManager PPointManager = new PricePointManager();
            List<PriceGroup> _PriceGroupList = new List<PriceGroup>();
            _PriceGroupList = _PGManager.PriceGroupConcession();

            PricePoint pricePointObj;
            int iTotalRow = gvMarkdownList.Rows.Count;
            int iRow = 0;

            foreach (PriceGroup pgroupItem in _PriceGroupList)
            {
                for (iRow = 0; iRow < iTotalRow; iRow++)
                {
                    pricePointObj = new PricePoint();
                    pricePointObj.StyleNo = gvMarkdownList.Rows[iRow].Cells[2].Text;
                    pricePointObj.BrandName = DDLBrand.SelectedValue;
                    pricePointObj.PGNo = pgroupItem.PGNo;
                    pricePointObj.Price_Type = genMemoObj.PriceType;
                    pricePointObj.Price = Convert.ToDecimal(gvMarkdownList.Rows[iRow].Cells[5].Text) + Convert.ToDecimal(_PGManager.AddValueToRegularPrice(pgroupItem.PGNo));
                    pricePointObj.Date_Posted = genMemoObj.MemoDate;
                    pricePointObj.f_Date = genMemoObj.FromDate;
                    pricePointObj.t_Date = genMemoObj.ToDate;
                    pricePointObj.Group_No = Convert.ToInt32(DDLSubArea.SelectedItem.Value);
                    //pricePointObj.Group_No = genMemoObj.GroupNumber;
                    pricePointObj.Memo_ID = genMemoObj.RecordNumber;
                    pricePointObj.Memo_No = genMemoObj.MemoNumber;
                    PPointManager.Save(pricePointObj);
                }
            }

            iTotalRow = gvNewMarkdown.Rows.Count;
            foreach (PriceGroup pgroupItem in _PriceGroupList)
            {
                for (iRow = 0; iRow < iTotalRow; iRow++)
                {
                    pricePointObj = new PricePoint();
                    pricePointObj.StyleNo = gvNewMarkdown.Rows[iRow].Cells[2].Text;
                    pricePointObj.BrandName = DDLBrand.SelectedValue;
                    pricePointObj.PGNo = pgroupItem.PGNo;
                    pricePointObj.Price_Type = genMemoObj.PriceType;
                    pricePointObj.Price = Convert.ToDecimal(gvNewMarkdown.Rows[iRow].Cells[5].Text) + Convert.ToDecimal(_PGManager.AddValueToRegularPrice(pgroupItem.PGNo));
                    pricePointObj.Date_Posted = genMemoObj.MemoDate;
                    pricePointObj.f_Date = genMemoObj.FromDate;
                    pricePointObj.t_Date = genMemoObj.ToDate;
                    pricePointObj.Group_No = Convert.ToInt32(DDLSubArea.SelectedItem.Value);
                    //pricePointObj.Group_No = genMemoObj.GroupNumber;
                    pricePointObj.Memo_ID = genMemoObj.RecordNumber;
                    pricePointObj.Memo_No = genMemoObj.MemoNumber;
                    PPointManager.Save(pricePointObj);
                }
            }
        }
        private void SavePricePointByCustomer(IRMS.Entities.GeneralMemoConcession genMemoObj)
        {
            PricePointManager PPointManager = new PricePointManager();
            CustomerInfoManager custInfoManager = new CustomerInfoManager();

            //List<PriceGroup> _PriceGroupList = new List<PriceGroup>();
            //_PriceGroupList = _PGManager.PriceGroupConcession();

            PricePoint pricePointObj;
            int iTotalRow = gvMarkdownList.Rows.Count;
            int iRow = 0;

            for (iRow = 0; iRow < iTotalRow; iRow++)
            {
                pricePointObj = new PricePoint();
                pricePointObj.StyleNo = gvMarkdownList.Rows[iRow].Cells[2].Text;
                pricePointObj.BrandName = DDLBrand.SelectedValue;
                pricePointObj.Price_Type = genMemoObj.PriceType;
                pricePointObj.PGNo = custInfoManager.GetCustomerByKey(genMemoObj.GroupNumber).PriceGroupNo;
                pricePointObj.Price = Convert.ToDecimal(gvMarkdownList.Rows[iRow].Cells[5].Text) + Convert.ToDecimal(_PGManager.AddValueToRegularPrice(pricePointObj.PGNo));
                pricePointObj.Date_Posted = genMemoObj.MemoDate;
                pricePointObj.f_Date = genMemoObj.FromDate;
                pricePointObj.t_Date = genMemoObj.ToDate;
                pricePointObj.Group_No = genMemoObj.GroupNumber;
                pricePointObj.Memo_ID = genMemoObj.RecordNumber;
                pricePointObj.Memo_No = genMemoObj.MemoNumber;
                PPointManager.Save(pricePointObj);
            }

            iTotalRow = gvNewMarkdown.Rows.Count;
            for (iRow = 0; iRow < iTotalRow; iRow++)
            {
                pricePointObj = new PricePoint();
                pricePointObj.StyleNo = gvNewMarkdown.Rows[iRow].Cells[2].Text;
                pricePointObj.BrandName = DDLBrand.SelectedValue;
                pricePointObj.Price_Type = genMemoObj.PriceType;
                pricePointObj.PGNo = custInfoManager.GetCustomerByKey(genMemoObj.GroupNumber).PriceGroupNo;
                pricePointObj.Price = Convert.ToDecimal(gvNewMarkdown.Rows[iRow].Cells[5].Text) + Convert.ToDecimal(_PGManager.AddValueToRegularPrice(pricePointObj.PGNo));
                pricePointObj.Date_Posted = genMemoObj.MemoDate;
                pricePointObj.f_Date = genMemoObj.FromDate;
                pricePointObj.t_Date = genMemoObj.ToDate;
                pricePointObj.Group_No = genMemoObj.GroupNumber;
                pricePointObj.Memo_ID = genMemoObj.RecordNumber;
                pricePointObj.Memo_No = genMemoObj.MemoNumber;
                PPointManager.Save(pricePointObj);
            }
        }
        private void SavePricePointByArea(IRMS.Entities.GeneralMemoConcession genMemoObj)
        {
            PricePointManager PPointManager = new PricePointManager();
            List<PriceGroup> _PriceGroupList = new List<PriceGroup>();
            _PriceGroupList = _PGManager.PriceGroupConcession();

            switch (genMemoObj.GroupNumber)
            {
                case 0:
                    {
                        _GroupAreaMemoManager.GroupAreaMemoByAllAreas();
                    }
                    break;
                case 99:
                    {
                        _GroupAreaMemoManager.GroupAreaMemoByAllProvinces();
                    }
                    break;
                default:
                    {
                        _GroupAreaMemoManager.GroupAreaMemoByAreaNumber(genMemoObj.GroupNumber);
                    }
                    break;
            }

            _GroupAreaMemoList = _GroupAreaMemoManager.GroupAreaMemoList;

            PricePoint pricePointObj;
            int iTotalRow = gvMarkdownList.Rows.Count;
            int iRow = 0;

            foreach (GroupAreaMemoClass gAreaMemo in _GroupAreaMemoList)
            {
                foreach (PriceGroup pgroupItem in _PriceGroupList)
                {
                    for (iRow = 0; iRow < iTotalRow; iRow++)
                    {
                        pricePointObj = new PricePoint();
                        pricePointObj.StyleNo = gvMarkdownList.Rows[iRow].Cells[2].Text;
                        pricePointObj.BrandName = genMemoObj.BrandName;
                        pricePointObj.PGNo = pgroupItem.PGNo;
                        pricePointObj.Price = Convert.ToDecimal(gvMarkdownList.Rows[iRow].Cells[5].Text) + Convert.ToDecimal(_PGManager.AddValueToRegularPrice(pgroupItem.PGNo));
                        pricePointObj.Price_Type = genMemoObj.PriceType;
                        pricePointObj.Date_Posted = genMemoObj.MemoDate;
                        pricePointObj.f_Date = genMemoObj.FromDate;
                        pricePointObj.Group_No = gAreaMemo.AreaGroupNo;
                        pricePointObj.Memo_ID = genMemoObj.RecordNumber;
                        pricePointObj.Memo_No = genMemoObj.MemoNumber;
                        PPointManager.Save(pricePointObj);
                    }
                }
            }

            iTotalRow = gvNewMarkdown.Rows.Count;
            foreach (GroupAreaMemoClass gAreaMemo in _GroupAreaMemoList)
            {
                foreach (PriceGroup pgroupItem in _PriceGroupList)
                {
                    for (iRow = 0; iRow < iTotalRow; iRow++)
                    {
                        pricePointObj = new PricePoint();
                        pricePointObj.StyleNo = gvNewMarkdown.Rows[iRow].Cells[2].Text;
                        pricePointObj.BrandName = genMemoObj.BrandName;
                        pricePointObj.PGNo = pgroupItem.PGNo;
                        pricePointObj.Price = Convert.ToDecimal(gvNewMarkdown.Rows[iRow].Cells[5].Text) + Convert.ToDecimal(_PGManager.AddValueToRegularPrice(pgroupItem.PGNo));
                        pricePointObj.Price_Type = genMemoObj.PriceType;
                        pricePointObj.Date_Posted = genMemoObj.MemoDate;
                        pricePointObj.f_Date = genMemoObj.FromDate;
                        pricePointObj.Group_No = gAreaMemo.AreaGroupNo;
                        pricePointObj.Memo_ID = genMemoObj.RecordNumber;
                        pricePointObj.Memo_No = genMemoObj.MemoNumber;
                        PPointManager.Save(pricePointObj);
                    }
                }
            }
        }
        protected void gvItems_SelectedIndexChangedEx(object sender, EventArgs e)
        {
            PriceManager pM = new PriceManager();
            PricePointManager ppM = new PricePointManager();
            GeneralMemoConcessionDetailManager gMCDM = new GeneralMemoConcessionDetailManager();

            bool bResult = false;

            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)
                bResult = true;
            else
            {
                dtNewMarkdownList = (DataTable)Session["NEWLIST"];
                ItemFoundResult = (from myRow in dtNewMarkdownList.AsEnumerable()
                                   where myRow.Field<string>("STYLE #") == gvItems.SelectedRow.Cells[1].Text
                                   select myRow);

                bResult = (ItemFoundResult.Count() > 0);
            }

            if (bResult == true)
            {
                this.lblDuplicateCount.Text = "{0} items found!";
                lblDuplicateCount.Text = string.Format(lblDuplicateCount.Text, 1);
                hfDuplicateStylePopupExtender.Show();
                txtCurrentPrice.Text = "";
                txtMarkDownPrice.Text = "0.00";
                return;
            }

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

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

            int GroupNo = -1;

            switch (rdioApplyPricePointTo.SelectedIndex)
            {
                case 0:
                    {
                        _GroupAreaMemoManager.GroupAreaMemo();
                        GroupNo = _GroupAreaMemoManager.GroupAreaMemoList[DDLAreaGroup.SelectedIndex].GroupNo;
                        if (GroupNo == 0)
                            GroupNo = 1;
                        else
                        {
                            if (GroupNo == 99)
                                GroupNo = 2;
                        }
                        break;
                    }
                case 1:
                    {
                        GroupNo = Convert.ToInt32(DDLSubArea.SelectedItem.Value);
                        break;
                    }
                case 2:
                    {
                        GroupNo = Convert.ToInt32(Session["CUSTOMER MD"]);
                        break;
                    }
            }

            pPoint = ppM.GetStyleCurrentPrice1(gvItems.SelectedRow.Cells[1].Text, DDLBrand.SelectedItem.Text,rdioApplyPricePointTo.SelectedValue.ToUpperInvariant(),GroupNo);
            if (pPoint != null)
            {
                dResult =  Convert.ToDouble(pPoint.Price);
                lblPriceStatus.Text = "MARKDOWN";
            }

            txtCurrentPrice.Text = string.Format("{0:0.00}",dResult);
            btnAddNewItem_ModalPopupExtender.Show();
        }
        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();
        }