コード例 #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);
            }
        }
コード例 #2
0
 //this contructor is use for clone book item from db
 public BookItem(int id, int info, LendingStatus lending)
 {
     this.id            = id;
     this.info          = info;
     this.lendingStatus = lending;
     if (getBookInfor() != null)
     {
         BookInfo = getBookInfor();
     }
 }
コード例 #3
0
        public void setStatus(LendingStatus status)
        {
            this.status = status;

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

            c1.CommandText = temp1;
            SQL_CON       SC1  = new SQL_CON();
            SqlDataReader rdr1 = SC1.execute_query(c1);
        }
コード例 #4
0
        public Lending(int ID, DateTime startDate, DateTime endDate, LendingStatus status, Customer Customer, DateTime returnDate, bool is_new)
        {
            this.lendingID  = ID;
            this.startDate  = startDate;
            this.endDate    = endDate;
            this.status     = status;
            this.Customer   = Customer;
            this.returnDate = returnDate;
            this.records    = new List <Record_in_lending>();
            foreach (Record_in_lending r in records)
            {
                this.records.Add(r);
            }

            if (is_new)
            {
                this.create_lending();
                Program.Lendings.Add(this);
            }
        }
コード例 #5
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            if (dateTimePicker.Value.Date.CompareTo(l.getCustomer().getLendingEndDate().Date) > 0)
            {
                string message4 = "End date is after customers lending tab expired";
                string title4   = "Error";
                MessageBox.Show(message4, title4);
                return;
            }

            if (dateTimePicker.Value.Date.CompareTo(DateTime.Now.Date) < 0)
            {
                string message3 = "Date invalid";
                string title3   = "Error";
                MessageBox.Show(message3, title3);
                return;
            }



            LendingStatus ls = (LendingStatus)Enum.Parse(typeof(LendingStatus), Status_comboBox.SelectedItem.ToString());

            l.setStatus(ls);
            l.setEndDate(dateTimePicker.Value);
            l.setReturnDate(dateTimePicker1.Value);
            if (Status_comboBox.SelectedItem.ToString() == "completed")
            {
                foreach (Record_in_lending ril in l.getRecords())
                {
                    ril.getRecord().setQuantityInStock(ril.getRecord().getQuantityInStock() + ril.getQuantity());
                    ril.getRecord().setQuantityInLending(ril.getRecord().getQuantityInLending() + ril.getQuantity());
                }
            }
            string message2 = "Update succeed";
            string title2   = "";

            MessageBox.Show(message2, title2);
        }
コード例 #6
0
        /// <summary>
        /// Config the specified lending.
        /// </summary>
        /// <param name="lending">Lending.</param>
        public void Config(LendingStatus lending)
        {
            using (var cylinderImageView = ItemView.FindViewById <ImageView>(Resource.Id.cylinderImageView))
            {
                var icon = ProductIcon.GetIcon(lending.ProductCode);

                if (icon != null)
                {
                    cylinderImageView.SetImageResource(icon.Value);
                }
            }

            using (var descriptionTextView = ItemView.FindViewById <TextView>(Resource.Id.descriptionTextView))
            {
                descriptionTextView.Text = lending.ShortDescription;
            }

            using (var quantityTextView = ItemView.FindViewById <TextView>(Resource.Id.quantityTextView))
            {
                var label = ItemView.Context.Resources.GetString(Resource.String.title_lending);
                quantityTextView.Text = String.Format("{0} {1}", lending.Quantity, label);
            }
        }