Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
0
 public void addRecord(Record_in_lending r)
 {
     this.records.Add(r);
 }
Ejemplo n.º 4
0
 public void addRecordInLending(Record_in_lending r)
 {
     this.Records_in_lendings.Add(r);
 }