示例#1
0
        private void CreateButton_Click(object sender, EventArgs e)
        {
            DateTime date1        = Convert.ToDateTime(dateTimePicker1.Value, CultureInfo.InvariantCulture);
            string   promo1       = DescrriptionBox.Text;
            string   percent      = PERCENTBOX.Text;
            double   convertedPer = 0;
            int      value;

            if (PERCENTBOX.Text != "" && int.TryParse(PERCENTBOX.Text, out value) == true)
            {
                convertedPer = Convert.ToDouble(percent, CultureInfo.InvariantCulture);
            }
            string description = textBox1.Text;

            if (DateTime.Compare(DateTime.Now, date1) >= 0)
            {
                MessageBox.Show(" You muse choose a date after today!.", "Wrong Input", MessageBoxButtons.OK);
            }
            else if (int.TryParse(PERCENTBOX.Text, out value) == false)
            {
                MessageBox.Show(" You muse choose a Numeric Number !", "Wrong Input", MessageBoxButtons.OK);
            }
            else if (DescrriptionBox.Text == "")
            {
                MessageBox.Show(" Please Generate a new code !", "Wrong Input", MessageBoxButtons.OK);
            }
            else
            {
                PromoCodes newpc = new PromoCodes(promo1, description, DateTime.Now, convertedPer, date1, true);

                pbm1.Fill_combo_box();
                this.Close();
            }
        }
示例#2
0
        public System.Collections.Generic.List <ProductInPurchases> Products_In_Purchase; //הכלה


        public Purchase(int ID, double price, Employee purchaseByEmployee, Customer purchaseByCustomer, DateTime date, PaymentMethod paymentMethod, PromoCodes purchasePromoCode, bool is_new)
        {
            this.purchaseID         = ID;
            this.purchasePrice      = price;
            this.purchaseByEmployee = purchaseByEmployee;
            this.purchaseByCustomer = purchaseByCustomer;
            this.purchaseDate       = date;
            this.paymentMethod      = paymentMethod;
            this.purchasePromoCode  = purchasePromoCode;
            this.purchaseByEmployee = purchaseByEmployee;

            this.Products_In_Purchase = new List <ProductInPurchases>();
            this.purchaseByCustomer.CustomersPurchases.Add(this);
            this.purchaseByEmployee.purchasesToCustomers.Add(this);


            if (purchasePromoCode != null)
            {
                this.purchasePromoCode.promoCodeInPurchase.Add(this);
            }


            if (is_new)
            {
                this.create_purchase();
                Program.purchases.Add(this);
            }
        }
示例#3
0
        public static void init_PromoCodes()//מילוי המערך מתוך בסיס הנתונים
        {
            SqlCommand c = new SqlCommand();

            c.CommandText = "EXECUTE dbo.Get_All_PromoCodes";
            SQL_CON       SC  = new SQL_CON();
            SqlDataReader rdr = SC.execute_query(c);

            promoCodes = new List <PromoCodes>();

            while (rdr.Read())
            {
                PromoCodes pc = new PromoCodes(rdr.GetValue(0).ToString(), rdr.GetValue(1).ToString(), DateTime.Parse(rdr.GetValue(2).ToString()), double.Parse(rdr.GetValue(3).ToString()), DateTime.Parse(rdr.GetValue(4).ToString()), false);
                promoCodes.Add(pc);
            }
        }
示例#4
0
        public static void init_Purchases()//מילוי המערך מתוך בסיס הנתונים
        {
            SqlCommand c = new SqlCommand();

            c.CommandText = "EXECUTE dbo.Get_All_Purchases";
            SQL_CON       SC  = new SQL_CON();
            SqlDataReader rdr = SC.execute_query(c);

            purchases = new List <Purchase>();

            while (rdr.Read())
            {
                PaymentMethod pm = (PaymentMethod)Enum.Parse(typeof(PaymentMethod), rdr.GetValue(5).ToString());
                PromoCodes    pc = seekPromoCode(rdr.GetValue(6).ToString());
                Purchase      pu = new Purchase(int.Parse(rdr.GetValue(0).ToString()), double.Parse(rdr.GetValue(1).ToString()), seekEmployee(int.Parse(rdr.GetValue(2).ToString())), seekCustomer(int.Parse(rdr.GetValue(3).ToString())), DateTime.Parse(rdr.GetValue(4).ToString()), pm, pc, false);
                purchases.Add(pu);
            }
        }
示例#5
0
        private void PromoCodeChooseBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            PromoCodes PC_new = Program.seekPromoCode(PromoCodeChooseBox.Text);

            DescrriptionBox.Text = PC_new.getPromoDescription() + Environment.NewLine + Environment.NewLine + "Expired date:" + PC_new.getPromoEndDate();
        }