Example #1
0
        public static void init_Lendings()//מילוי רשימת ההשאלות מתוך בסיס הנתונים
        {
            SqlCommand c = new SqlCommand();

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

            Lendings = new List <Lending>();
            DateTime DT;

            while (rdr.Read())
            {
                if (rdr.GetValue(5).ToString().Equals(""))
                {
                    DT = DateTime.MinValue;
                }
                else
                {
                    DT = DateTime.Parse(rdr.GetValue(5).ToString());
                }

                LendingStatus ls = (LendingStatus)Enum.Parse(typeof(LendingStatus), rdr.GetValue(3).ToString());
                Lending       l  = new Lending(int.Parse(rdr.GetValue(0).ToString()), DateTime.Parse(rdr.GetValue(1).ToString()), DateTime.Parse(rdr.GetValue(2).ToString()), ls, GetCustomerByEmail(rdr.GetValue(4).ToString()), DT, false);
                Lendings.Add(l);
            }
        }
Example #2
0
 public Record_in_lending(Lending lending, Record record, int quantity, bool is_new)
 {
     this.record   = record;
     this.lending  = lending;
     this.quantity = quantity;
     if (is_new)
     {
         this.create_Record_in_lending();
     }
 }
Example #3
0
        private void submit_button_Click(object sender, EventArgs e)
        {
            if (IsCustomer && IsBarCode && records.Count() > 0)
            {
                if (date_piker.Value.Date.CompareTo(DateTime.Now.Date) < 0)
                {
                    string message3 = "Date invalid";
                    string title3   = "Error";
                    MessageBox.Show(message3, title3);
                }
                else
                {
                    if (date_piker.Value.Date.CompareTo(customer.getLendingEndDate().Date) > 0)
                    {
                        string message4 = "End date is after customers lending tab expired";
                        string title4   = "Error";
                        MessageBox.Show(message4, title4);
                    }


                    else
                    {
                        isSubmit = true;
                        DateTime dt = date_piker.Value;
                        Lending  l  = new Lending(Program.Lendings.Count() + 1, DateTime.Now, dt, (LendingStatus)Enum.Parse(typeof(LendingStatus), "inLending".ToString()), customer, DateTime.MinValue, true);
                        Record   r;
                        int      q;

                        for (int i = 0; i < textBoxes.Count(); i = i + 4)
                        {
                            if (textBoxes[i].Text != "")
                            {
                                r = Program.GetRecordByQR(int.Parse(textBoxes[i].Text));
                                q = int.Parse(textBoxes[i + 3].Text);
                                Record_in_lending ril = new Record_in_lending(l, r, q, true);
                                l.addRecord(ril);
                                r.addRecordInLending(ril);
                                r.setQuantityInLending(r.getQuantityInLending() + q);
                            }
                        }
                        customer.add_lending(l);
                        string message1 = "Lent Succsessful";
                        string title1   = "";
                        MessageBox.Show(message1, title1);
                        submit_button.Hide();
                    }
                }
            }
            else
            {
                string message2 = "Please fill all details";
                string title2   = "Error";
                MessageBox.Show(message2, title2);
            }
        }
Example #4
0
        private Lending GetLending_ByCustomerAndDate(int id, DateTime dt)
        {
            Lending temp = Program.Lendings.First();

            foreach (Lending l in Program.Lendings)
            {
                if (l.getCustomer().getCustomerID() == id && l.getStartDate() == dt)
                {
                    temp = l;
                }
            }
            return(temp);
        }
Example #5
0
        public static Lending GetLendingByID(int id)
        {
            Lending temp = Lendings.First();

            foreach (Lending l in Lendings)
            {
                if (l.getLendingID() == id)
                {
                    temp = l;
                }
            }
            return(temp);
        }
Example #6
0
        public static void init_Records_in_Lendings()//מילוי רשימת התקיטים בהשאלות מתוך בסיס הנתונים
        {
            SqlCommand c = new SqlCommand();

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


            while (rdr.Read())
            {
                Lending           l   = GetLendingByID(int.Parse(rdr.GetValue(0).ToString()));
                Record            r   = GetRecordByQR(int.Parse(rdr.GetValue(1).ToString()));
                Record_in_lending ril = new Record_in_lending(l, r, int.Parse(rdr.GetValue(2).ToString()), false);
                l.addRecord(ril);
                r.addRecordInLending(ril);
            }
        }
Example #7
0
 public Lend_Form(Lending l, string r)
 {
     this.l = l;
     InitializeComponent();
     //if (LendingID != 0)
     //{
     //    this.l = Program.GetLendingByID(LendingID);
     // }
     // else
     // {
     //    this.l = GetLending_ByCustomerAndDate(CustomerID, DateTime);
     // }
     textBoxes = new List <TextBox>();
     textBoxes.Add(textBox1);
     textBoxes.Add(textBox2);
     textBoxes.Add(textBox3);
     textBoxes.Add(textBox4);
     textBoxes.Add(textBox5);
     textBoxes.Add(textBox6);
     textBoxes.Add(textBox7);
     textBoxes.Add(textBox8);
     textBoxes.Add(textBox9);
     textBoxes.Add(textBox10);
     textBoxes.Add(textBox11);
     textBoxes.Add(textBox12);
     textBoxes.Add(textBox13);
     textBoxes.Add(textBox14);
     textBoxes.Add(textBox15);
     textBoxes.Add(textBox16);
     textBoxes.Add(textBox17);
     textBoxes.Add(textBox18);
     textBoxes.Add(textBox19);
     textBoxes.Add(textBox20);
     this.role = r;
     foreach (TextBox tb in textBoxes)
     {
         tb.ReadOnly = true;
     }
 }
Example #8
0
 public void add_lending(Lending lending)
 {
     this.Lendings.Add(lending);
 }