internal bool InsertNewDiscount(Discount instance)
        {
            base.com.CommandText = "spInsertDiscount";
            base.com.Parameters.AddWithValue("_Value", instance.Value);
            base.com.Parameters.AddWithValue("_DateFrom", instance.ValidFrom);
            base.com.Parameters.AddWithValue("_DateTo", instance.ValidTo);
            base.com.Parameters.AddWithValue("_KioskAssign", instance.KioskAssign);
            base.com.Parameters.AddWithValue("_ProductAssign", instance.ProductAssign);
            base.com.Parameters.AddWithValue("_CreatedBy", instance.CreatedBy);
            base.com.Parameters.AddWithValue("_Remarks", instance.Remarks);

            int res = 0;

            try
            {
                res = Convert.ToInt32( base.com.ExecuteScalar());
            }catch(Exception ee){

            }

            return res > 0;
        }
        public static List<Discount> GetAllData()
        {
            var dal = new DiscountDAL();
            var collection = new List<Discount>();

            foreach (DataRow row in dal.GetAllData().Rows)
            {
                var instance = new Discount();
                instance.Bind(row);

                collection.Add(instance);
            }

            return collection;
        }
        public static bool InsertNewDiscount(Discount instance)
        {
            var dal = new DiscountDAL();

            return dal.InsertNewDiscount(instance);
        }
        protected void btnDiscountSave_Click(object sender, EventArgs e)
        {
            // kiosk validation
            if(lbxKioskSel.Items.Count == 0){
                (Master as Frame).PopUp("Kiosk is Required");
                return;
            }

            decimal value = Convert.ToDecimal(tbValue.Text);
            DateTime fromDate = DateTime.Parse(tbValidFrom.Text);
            DateTime? toDate = null;
            if (tbValidTo.Text != string.Empty)
            {
                toDate = DateTime.Parse(tbValidTo.Text);
            }
            string kioskAssign = null;

            foreach(ListItem li in lbxKioskSel.Items){
                kioskAssign += li.Value + ",";
            }

            kioskAssign = kioskAssign.Substring(0, kioskAssign.Length - 1);

            string productAssign = null;

            if(lbxProductSel.Items.Count != 0){
                foreach(ListItem li in lbxProductSel.Items){
                    productAssign += li.Value + ",";
                }
                productAssign = productAssign.Substring(0, productAssign.Length - 1);
            }

            string createdby = GlobalAccess.EmpID;
            string remarks = tbRemarks.Text;
            //
            var instance = new Discount();
            instance.Value = value;
            instance.ValidFrom = fromDate;
            instance.ValidTo = toDate;
            instance.KioskAssign = kioskAssign;
            instance.ProductAssign = productAssign;
            instance.CreatedBy = createdby;
            instance.Remarks = remarks;

            bool isInsert = Discount.InsertNewDiscount(instance);
            //
            if (isInsert)
            {
                (Master as Frame).PopUp("Insert Discount Success");
                CallDatagrid();
                mvMain.SetActiveView(vwMain);
            }
            else
            {
                (Master as Frame).PopUp("Insert Discount Failed");
            }
        }
        public static bool InsertNewDiscount(Discount instance)
        {
            var dal = new DiscountDAL();

            return(dal.InsertNewDiscount(instance));
        }