예제 #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);
            }
        }
        public void create_Record_in_sale()
        {
            string     temp = "dbo.SP_AddRecordInSale " + sale.getSaleID().ToString() + " , " + record.getQrCode().ToString() + " , " + this.getQuantity().ToString();
            SqlCommand c    = new SqlCommand();

            c.CommandText = temp;
            SQL_CON       SC  = new SQL_CON();
            SqlDataReader rdr = SC.execute_query(c);
        }
예제 #3
0
        public void create_Record_in_lending()
        {
            string temp = "dbo.sp_AddRecordInLending " + this.getLending().getLendingID().ToString() + " , " + this.getRecord().getQrCode().ToString() + " , "
                          + this.getQuantity().ToString();
            SqlCommand c = new SqlCommand();

            c.CommandText = temp;
            SQL_CON       SC  = new SQL_CON();
            SqlDataReader rdr = SC.execute_query(c);
        }
예제 #4
0
        public void setEndDate(DateTime DT)
        {
            this.endDate = DT;
            string     temp1 = "dbo.sp_LendingEndDate " + this.getLendingID().ToString() + " , '" + this.endDate.ToString() + " '";
            SqlCommand c1    = new SqlCommand();

            c1.CommandText = temp1;
            SQL_CON       SC1  = new SQL_CON();
            SqlDataReader rdr1 = SC1.execute_query(c1);
        }
예제 #5
0
        public void create_sale()
        {
            string temp = "dbo.SP_AddSale " + this.getSaleID().ToString() + " , ' " + this.getDate().ToString() +
                          " ' , " + this.getTotalCost().ToString()
                          + " , " + this.getPaymentAccount().ToString() + " ,  [" + this.Customer.getEmail().ToString() + "]";
            SqlCommand c = new SqlCommand();

            c.CommandText = temp;
            SQL_CON       SC  = new SQL_CON();
            SqlDataReader rdr = SC.execute_query(c);
        }
예제 #6
0
        public void create_lending()
        {
            string temp = "dbo.sp_AddLending " + this.getLendingID().ToString() + " , ' " + this.getStartDate().ToString() + " ' ,  '"
                          + this.getEndDate().ToString() + " ' , " + this.getStatus().ToString() + " , [" + this.getCustomer().getEmail().ToString() + "] , ' "
                          + this.getReturnDate().ToString() + " ' ";
            SqlCommand c = new SqlCommand();

            c.CommandText = temp;
            SQL_CON       SC  = new SQL_CON();
            SqlDataReader rdr = SC.execute_query(c);
        }
예제 #7
0
        public void create_record()
        {
            string temp = "dbo.sp_AddRecord " + this.getQrCode().ToString() + " , " + this.getRecordName().ToString() + " , "
                          + this.getArtist().ToString() + " , " + this.getGener().ToString() + " , " + this.getPrice().ToString() + " , "
                          + this.getQuantityInStock().ToString();
            SqlCommand c = new SqlCommand();

            c.CommandText = temp;
            SQL_CON       SC  = new SQL_CON();
            SqlDataReader rdr = SC.execute_query(c);
        }
예제 #8
0
        public void setStatus(OrderStatus status)
        {
            this.orderStatus = status;

            string     temp1 = "dbo.sp_ordersStatus " + this.getID().ToString() + " , " + status.ToString();
            SqlCommand c1    = new SqlCommand();

            c1.CommandText = temp1;
            SQL_CON       SC1  = new SQL_CON();
            SqlDataReader rdr1 = SC1.execute_query(c1);
        }
예제 #9
0
        public void setQuantityInStock(int quantity)
        {
            this.quantityInStock = quantity;

            string tempc = "dbo.sp_UpdateRecord " + this.getQrCode().ToString() + " , "
                           + quantity.ToString();
            SqlCommand cc = new SqlCommand();

            cc.CommandText = tempc;
            SQL_CON       SCc  = new SQL_CON();
            SqlDataReader rdrc = SCc.execute_query(cc);
        }
        public void setarrivedQuantity(int num)
        {
            this.arrivedQuantity += num;

            string temp = "dbo.sp_updateArriveQuantity " + num.ToString() + " , " + order.getID().ToString()
                          + " , " + this.getRecord().getQrCode().ToString();
            SqlCommand c = new SqlCommand();

            c.CommandText = temp;
            SQL_CON       SC  = new SQL_CON();
            SqlDataReader rdr = SC.execute_query(c);
        }
예제 #11
0
        public void updateTotalCost()
        {
            foreach (Record_in_sale r in this.records)
            {
                this.totalCost = this.totalCost + (r.getRecord().getPrice() * r.getQuantity());
            }
            string     temp = "dbo.SP_UpdateTotalCost " + this.getSaleID().ToString() + " , " + this.getTotalCost().ToString();
            SqlCommand c    = new SqlCommand();

            c.CommandText = temp;
            SQL_CON       SC  = new SQL_CON();
            SqlDataReader rdr = SC.execute_query(c);
        }
예제 #12
0
        public static void init_Returnings()//מילוי רשימת ההחזרות מתוך בסיס הנתונים
        {
            SqlCommand c = new SqlCommand();

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

            Returnings = new List <Returning>();

            while (rdr.Read())
            {
                Returning r = new Returning(int.Parse(rdr.GetValue(0).ToString()), DateTime.Parse(rdr.GetValue(1).ToString()), GetRecordByQR(int.Parse(rdr.GetValue(3).ToString())), GetCustomerByEmail(rdr.GetValue(2).ToString()), false);
                Returnings.Add(r);
            }
        }
예제 #13
0
        public static void init_Vendors()//מילוי רשימת העובדים מתוך בסיס הנתונים
        {
            SqlCommand c = new SqlCommand();

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

            Vendors = new List <Vendor>();

            while (rdr.Read())
            {
                Vendor v = new Vendor(int.Parse(rdr.GetValue(0).ToString()),
                                      int.Parse(rdr.GetValue(1).ToString()), rdr.GetValue(2).ToString(), false);
                Vendors.Add(v);
            }
        }
예제 #14
0
        public static void init_Sales()//מילוי רשימת המכירות מתוך בסיס הנתונים
        {
            SqlCommand c = new SqlCommand();

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

            Sales = new List <Sale>();

            while (rdr.Read())
            {
                PaymentMethod pm = (PaymentMethod)Enum.Parse(typeof(PaymentMethod), rdr.GetValue(3).ToString());
                Sale          s  = new Sale(int.Parse(rdr.GetValue(0).ToString()), DateTime.Parse(rdr.GetValue(1).ToString()), pm, GetCustomerByEmail(rdr.GetValue(4).ToString()), false);
                Sales.Add(s);
            }
        }
예제 #15
0
        public static void init_Records()//מילוי רשימת התקיטים מתוך בסיס הנתונים
        {
            SqlCommand c = new SqlCommand();

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

            Records = new List <Record>();

            while (rdr.Read())
            {
                Genere g = (Genere)Enum.Parse(typeof(Genere), rdr.GetValue(3).ToString());
                Record r = new Record(int.Parse(rdr.GetValue(0).ToString()), rdr.GetValue(1).ToString(), rdr.GetValue(2).ToString(), g, float.Parse(rdr.GetValue(4).ToString()), int.Parse(rdr.GetValue(5).ToString()), int.Parse(rdr.GetValue(6).ToString()), false);
                Records.Add(r);
            }
        }
예제 #16
0
        public static void init_Orders()//מילוי רשימת העובדים מתוך בסיס הנתונים
        {
            SqlCommand c = new SqlCommand();

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

            Orders = new List <Order>();

            while (rdr.Read())
            {
                OrderStatus os = (OrderStatus)Enum.Parse(typeof(OrderStatus), rdr.GetValue(3).ToString());
                Order       o  = new Order(int.Parse(rdr.GetValue(0).ToString()), DateTime.Parse(rdr.GetValue(1).ToString()), DateTime.Parse(rdr.GetValue(2).ToString()), os, GetVendorByID(int.Parse(rdr.GetValue(4).ToString())), false);
                Orders.Add(o);
            }
        }
예제 #17
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);
            }
        }
예제 #18
0
        public static void init_Employees()//מילוי רשימת העובדים מתוך בסיס הנתונים
        {
            SqlCommand c = new SqlCommand();

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

            Employees = new List <Employee>();

            while (rdr.Read())
            {
                EmplyeeStatus es = (EmplyeeStatus)Enum.Parse(typeof(EmplyeeStatus), rdr.GetValue(4).ToString());
                Role          r  = (Role)Enum.Parse(typeof(Role), rdr.GetValue(5).ToString());
                Employee      e  = new Employee(int.Parse(rdr.GetValue(0).ToString()), rdr.GetValue(1).ToString(), rdr.GetValue(2).ToString(), DateTime.Parse(rdr.GetValue(3).ToString()), es, r, DateTime.Parse(rdr.GetValue(6).ToString()), rdr.GetValue(7).ToString(), false);
                Employees.Add(e);
            }
        }
예제 #19
0
        public static void init_Records_in_Orders()//מילוי רשימת התקיטים בהזמנות מתוך בסיס הנתונים
        {
            SqlCommand c = new SqlCommand();

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


            while (rdr.Read())
            {
                Order           o   = GetOrderByID(int.Parse(rdr.GetValue(0).ToString()));
                Record          r   = GetRecordByQR(int.Parse(rdr.GetValue(1).ToString()));
                Record_in_order rio = new Record_in_order(o, r, int.Parse(rdr.GetValue(2).ToString()), int.Parse(rdr.GetValue(3).ToString()), false);
                o.addRecord(rio);
                r.addRecordInOrder(rio);
            }
        }
예제 #20
0
        public static void init_Customers()//מילוי רשימת הלקוחות מתוך בסיס הנתונים
        {
            SqlCommand c = new SqlCommand();

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

            Customers = new List <Customer>();

            while (rdr.Read())
            {
                Genere   g  = (Genere)Enum.Parse(typeof(Genere), rdr.GetValue(5).ToString());
                Customer cu = new Customer(rdr.GetValue(0).ToString(), int.Parse(rdr.GetValue(1).ToString()), rdr.GetValue(2).ToString(), rdr.GetValue(3).ToString(), DateTime.Parse(rdr.GetValue(4).ToString()),
                                           g, Boolean.Parse(rdr.GetValue(6).ToString()), DateTime.Parse(rdr.GetValue(7).ToString()), rdr.GetValue(8).ToString(), rdr.GetValue(9).ToString(),
                                           int.Parse(rdr.GetValue(10).ToString()), rdr.GetValue(11).ToString(), false);
                Customers.Add(cu);
            }
        }
예제 #21
0
        public static void init_Records_in_Sales()//מילוי רשימת התקליטים במכירות מתוך בסיס הנתונים
        {
            SqlCommand c = new SqlCommand();

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

            while (rdr.Read())
            {
                Record         r   = GetRecordByQR(int.Parse(rdr.GetValue(1).ToString()));
                Sale           s   = GetSaleByID(int.Parse(rdr.GetValue(0).ToString()));
                Record_in_sale ris = new Record_in_sale(r, s, int.Parse(rdr.GetValue(2).ToString()), false);
                r.addRecordInSale(ris);
                s.addRecord(ris);
            }
            foreach (Sale s in Program.Sales)
            {
                s.updateTotalCost();
            }
        }