private void BtnSearchUser_Click(object sender, EventArgs e)
        {
            mbll     = new MaterialBLL();
            material = new Material();

            int  n;
            bool isNumeric = int.TryParse(txtMaterialID.Text, out n);

            if (isNumeric)
            {
                material = mbll.Get(n);
            }

            if (material != null)
            {
                txtTitle.Text = material.Title;

                txtAuthor.Text = material._Author.AuthorName;
                if (material.ISBN != string.Empty || material.ISBN.Length != null)
                {
                    txtISBN.Text = material.ISBN;
                }

                txtPages.Text = material.NumberOfPages.ToString();

                if (true)
                {
                    txtPublishDate.Text = material.PublishYear.Year.ToString();
                }


                if (material._PublishHouse._PublishHouse != string.Empty || material._PublishHouse._PublishHouse != null)
                {
                    txtPublishHouse.Text = material._PublishHouse._PublishHouse;
                }


                txtQuantity.Text = material.Quantity.ToString();

                if (material.IsActive == true)
                {
                    comboActiveMaterial.SelectedIndex = 0;
                }
                else
                {
                    comboActiveMaterial.SelectedIndex = 1;
                }

                BindGenre(material._Genre);
                BindMaterialType(material._MaterialType);
                BindShelf(material._Shelf);
                BindLanguage(material._Language);
            }
        }
Ejemplo n.º 2
0
        //public DeleteMaterialForm(Material material)
        //{
        //    InitializeComponent();

        //    materialbll = new MaterialBLL();

        //    txtMaterialID.Text = material.MaterialId.ToString();
        //    txtTitle.Text = material.Title;
        //    txtGenre.Text = material._Genre._Genre;
        //    txtLanguage.Text = material._Language._Language;
        //    txtAuthor.Text = material._Author.AuthorName;

        //        txtISBN.Text = material.ISBN;

        //    txtMaterialType.Text = material._MaterialType._MaterialType;

        //    txtPages.Text = material.NumberOfPages.ToString();


        //        txtPublishDate.Text = material.PublishYear.Year.ToString();


        //        txtPublishHouse.Text = material._PublishHouse._PublishHouse;



        //    txtQuantity.Text = material.Quantity.ToString();
        //}

        private void BtnSearchMaterial_Click(object sender, EventArgs e)
        {
            try
            {
                materialbll = new MaterialBLL();
                material    = new Material();

                int  n;
                bool isNumeric = int.TryParse(txtMaterialID.Text, out n);

                if (isNumeric)
                {
                    material = materialbll.Get(n);
                }

                if (material != null)
                {
                    txtTitle.Text    = material.Title;
                    txtGenre.Text    = material._Genre._Genre;
                    txtLanguage.Text = material._Language._Language;
                    txtAuthor.Text   = material._Author.AuthorName;
                    if (material.ISBN.Length > 1)
                    {
                        txtISBN.Text = material.ISBN;
                    }
                    txtMaterialType.Text = material._MaterialType._MaterialType;

                    txtPages.Text = material.NumberOfPages.ToString();

                    if (true)
                    {
                        txtPublishDate.Text = material.PublishYear.Year.ToString();
                    }


                    if (material._PublishHouse._PublishHouse.Length > 1)
                    {
                        txtPublishHouse.Text = material._PublishHouse._PublishHouse;
                    }


                    txtQuantity.Text = material.Quantity.ToString();
                }
            }
            catch (Exception)
            {
            }
        }
        private void btnSearch_Click(object sender, EventArgs e)
        {
            try
            {
                //Subscriber
                subscriber = subscriberBLL.Get(int.Parse(txtSubscriberID.Text));

                txtName.Text           = subscriber.Name;
                txtAddress.Text        = subscriber.Address;
                txtEmail.Text          = subscriber.Email;
                txtPhoneNumber.Text    = subscriber.PersonalNo;
                txtPersonalNumber.Text = subscriber.PersonalNo;


                //Material
                material                = materialBLL.Get(int.Parse(txtMaterialID.Text));
                txtMaterialName.Text    = material.Title;
                txtMaterialType.Text    = material.MaterialId.ToString();
                txtOverallQuantity.Text = material.Quantity.ToString();
                txtStockQuantity.Text   = material.AvailableCoppies.ToString();

                if (material.AvailableCoppies > 0)
                {
                    txtAvailability.Text = "Available";
                }

                else
                {
                    txtAvailability.Text = "Unavailable";
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void BtnSearch_Click_1(object sender, EventArgs e)
        {
            int  n;
            bool isNumeric = int.TryParse(txtSubscriberID.Text, out n);

            int  m;
            bool isMaterialId = int.TryParse(txtMaterialID.Text, out m);

            if (isNumeric && isMaterialId)
            {
                sbll = new SubscriberBLL();
                rbll = new ReservationBLL();
                mbll = new MaterialBLL();


                mbo = mbll.Get(m);
                sbo = sbll.Get(n);



                if (sbo != null && mbo.MaterialId > 0)
                {
                    re = rbll.GetReservationBySubscriberIdAndMaterialId(sbo.SubscriberId, mbo.MaterialId);

                    txtName.Text           = $"{sbo.Name} {sbo.LastName}";
                    txtAddress.Text        = sbo.Address;
                    txtEmail.Text          = sbo.Email;
                    txtPhoneNumber.Text    = sbo.PhoneNo;
                    txtPersonalNumber.Text = sbo.PersonalNo;

                    txtMaterialName.Text = mbo.Title;
                    txtMaterialType.Text = mbo._MaterialType._MaterialType;
                    txtAuthor.Text       = mbo._Author.AuthorName;
                    txtLocated.Text      = mbo._Shelf.Location;

                    if (re == null)
                    {
                        txtReserved.Text = "No";
                    }
                    else
                    {
                        txtReserved.Text = "Yes";
                    }



                    if (mbo.AvailableCoppies > 0)
                    {
                        txtAvailability.Text = "Yes";
                    }
                    else
                    {
                        txtAvailability.Text = "No";
                    }
                }
                else
                {
                    if (sbo == null && mbo.MaterialId < 1)
                    {
                        MessageBox.Show($"Material and Subscriber are not found", $"ERROR", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else if (sbo == null)
                    {
                        MessageBox.Show($"Subscriber is not found", $"ERROR", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else if (mbo.MaterialId < 1)
                    {
                        MessageBox.Show($"Material is not found", $"ERROR", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            else if (txtMaterialID.Text == string.Empty && txtSubscriberID.Text == string.Empty)
            {
                MessageBox.Show($"Material and Subscriber are empty", $"ERROR", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (txtMaterialID.Text == string.Empty)
            {
                MessageBox.Show($"Material ID field is empty", $"ERROR", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (txtSubscriberID.Text == string.Empty)
            {
                MessageBox.Show($"Subscriber ID field is empty", $"ERROR", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                MessageBox.Show($"Material or Subscriber is not valid", $"ERROR", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }