public int CreateUpdateNDCDiscount(NDC_Discounts ud)
        {
            int NDC_DiscountID = 0;
            using (FDBEntities db = new FDBEntities())
            {
                if (ud.NDC_DiscountID > 0)
                {
                    NDC_Discounts temp = db.NDC_Discounts.Where(u => u.NDC_DiscountID == ud.NDC_DiscountID).FirstOrDefault();

                    if (temp != null)
                    {
                        temp.NDC = ud.NDC;
                        temp.Discount_Percent = ud.Discount_Percent;
                        temp.FacilityID = ud.FacilityID;
                        temp.ProductTypeID = ud.ProductTypeID;
                    }
                }
                else
                {
                    db.NDC_Discounts.Add(ud);
                }

                int x = db.SaveChanges();
                if (x > 0)
                {
                    NDC_DiscountID = ud.NDC_DiscountID;
                }
            }

            return NDC_DiscountID;
        }
Esempio n. 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            double discount = 0;
            double.TryParse(txtDiscount.Text, out discount);
            NDC_Discounts NDC_DiscountObj = new NDC_Discounts();
            NDC_DiscountObj.NDC_DiscountID = NDC_DISCOUNTID;
            NDC_DiscountObj.NDC = txtNDC.Text;
            NDC_DiscountObj.FacilityID = int.Parse(ddlFacility.SelectedValue.ToString());
            NDC_DiscountObj.ProductTypeID = int.Parse(ddlProductType.SelectedValue);
            NDC_DiscountObj.Discount_Percent = discount;
            int id=NDCDiscountsServices.Instance.CreateUpdateNDCDiscount(NDC_DiscountObj);
            if (id > 0)
            {
                Common.Instance.ShowAlertMsg("NDC_Discount is saved", true, DivMsg);
            }
            else
            {

                Common.Instance.ShowAlertMsg("NDC_Discount is Unsaved", false, DivMsg);
            }
        }