protected void grdSalesPrice_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            PNK_SalesPrice productcatObj = new PNK_SalesPrice();

            productcatObj.Id              = DBConvert.ParseInt(((Label)grdSalesPrice.Rows[e.RowIndex].FindControl("lbID")).Text);
            productcatObj.ProductId       = ProductId;
            productcatObj.StoreGroup      = ((DropDownList)grdSalesPrice.Rows[e.RowIndex].FindControl("drpStoreGroup")).SelectedValue;
            productcatObj.SalesPriceId    = ((DropDownList)grdSalesPrice.Rows[e.RowIndex].FindControl("drpSalesPriceType")).SelectedValue;
            productcatObj.UnitOfMeasureId = ((DropDownList)grdSalesPrice.Rows[e.RowIndex].FindControl("drpUnit")).SelectedValue;
            string startingDate = ((TextBox)grdSalesPrice.Rows[e.RowIndex].FindControl("txtStartingDate")).Text;

            productcatObj.StartingDate = startingDate != "" ? DateTime.ParseExact(startingDate, "dd/MM/yyyy", CultureInfo.InvariantCulture) : DateTime.MinValue;

            string endingDate = ((TextBox)grdSalesPrice.Rows[e.RowIndex].FindControl("txtEndingDate")).Text;

            productcatObj.EndingDate = endingDate != "" ? DateTime.ParseExact(endingDate, "dd/MM/yyyy", CultureInfo.InvariantCulture) : DateTime.MinValue;

            string unitPrice = ((TextBox)grdSalesPrice.Rows[e.RowIndex].FindControl("txtUnitPrice")).Text;

            productcatObj.UnitPrice   = DBConvert.ParseDecimal(unitPrice);
            productcatObj.OriginPrice = DBConvert.ParseDecimal(unitPrice);

            string dealPrice = ((TextBox)grdSalesPrice.Rows[e.RowIndex].FindControl("txtDealPrice")).Text;

            productcatObj.DealPrice = dealPrice == "" ? DBConvert.ParseDecimal(unitPrice) : DBConvert.ParseDecimal(dealPrice);


            //productcatObj.UnitPrice = DBConvert.ParseDecimal(((TextBox)grdSalesPrice.Rows[e.RowIndex].FindControl("txtUnitPrice")).Text);
            //productcatObj.DealPrice = DBConvert.ParseDecimal(((TextBox)grdSalesPrice.Rows[e.RowIndex].FindControl("txtDealPrice")).Text);

            grdSalesPrice.EditIndex = -1;
            Save(productcatObj);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="productId"></param>
        /// <param name="type">==NULL mặc định hình</param>
        /// <param name="type">==1:map</param>
        private void BindData()
        {
            SalesPriceBLL bll = new SalesPriceBLL();

            lst = bll.GetList(ProductId, string.Empty, DateTime.MinValue, DateTime.MinValue, 1, 1000, out total);
            if (lst.Count() > 0)
            {
                grdSalesPrice.DataSource = lst;
                grdSalesPrice.DataBind();
            }
            else
            {
                PNK_SalesPrice pnk = new PNK_SalesPrice();
                DataTable      dt  = Common.UtilityLocal.ObjectToData(pnk);
                grdSalesPrice.DataSource = dt;
                grdSalesPrice.DataBind();

                //grdSalesPrice.Columns[4].Visible = false;
                //foreach (GridViewRow row in grdSalesPrice.Rows)
                //{
                //    if (row.RowType == DataControlRowType.DataRow)
                //    {
                //        LinkButton lb = ((LinkButton)row.FindControl("lnkRemove"));
                //        if (lb != null)
                //        {
                //            lb.Visible = false;
                //        }
                //    }
                //}
            }
        }
        protected void AddNew(object sender, EventArgs e)
        {
            PNK_SalesPrice productcatObj = new PNK_SalesPrice();

            productcatObj.ProductId       = ProductId;
            productcatObj.StoreGroup      = ((DropDownList)grdSalesPrice.FooterRow.FindControl("drpStoreGroup")).SelectedValue;
            productcatObj.SalesPriceId    = ((DropDownList)grdSalesPrice.FooterRow.FindControl("drpSalesPriceType")).SelectedValue;
            productcatObj.UnitOfMeasureId = ((DropDownList)grdSalesPrice.FooterRow.FindControl("drpUnit")).SelectedValue;

            string startingDate = ((TextBox)grdSalesPrice.FooterRow.FindControl("txtStartingDate")).Text;

            productcatObj.StartingDate = startingDate != "" ? DateTime.Parse(startingDate, new CultureInfo("en-US")) : DateTime.MinValue;

            string endingDate = ((TextBox)grdSalesPrice.FooterRow.FindControl("txtEndingDate")).Text;

            productcatObj.EndingDate = endingDate != "" ? DateTime.Parse(endingDate, new CultureInfo("en-US")) : DateTime.MinValue;

            string unitPrice = ((TextBox)grdSalesPrice.FooterRow.FindControl("txtUnitPrice")).Text;

            productcatObj.UnitPrice   = DBConvert.ParseDecimal(unitPrice);
            productcatObj.OriginPrice = DBConvert.ParseDecimal(unitPrice);

            string dealPrice = ((TextBox)grdSalesPrice.FooterRow.FindControl("txtDealPrice")).Text;

            productcatObj.DealPrice = dealPrice == "" ? DBConvert.ParseDecimal(unitPrice) : DBConvert.ParseDecimal(((TextBox)grdSalesPrice.FooterRow.FindControl("txtDealPrice")).Text);

            Save(productcatObj);
        }
        /// <summary>
        /// Save location
        /// </summary>
        private int Save(PNK_SalesPrice productcatObj)
        {
            int priceId = productcatObj.Id;
            Generic <PNK_SalesPrice> genericBLL = new Generic <PNK_SalesPrice>();

            if (priceId == int.MinValue)
            {
                genericBLL.Insert(productcatObj);
            }
            else
            {
                PNK_SalesPrice productcatObjCurrent = new PNK_SalesPrice();
                string[]       fields = { "Id" };
                productcatObjCurrent.Id = priceId;
                productcatObjCurrent    = genericBLL.Load(productcatObj, fields);

                genericBLL.Update(productcatObjCurrent, productcatObj, fields);
            }

            BindData();

            return(priceId);
        }