Beispiel #1
0
 private void Updatebutton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         BloodInventory p = new BloodInventory()
         {
             BloodInvenoryID = (SearchtextBox.Text),
             BloodGroup      = BloodGrouptextBox.Text,
             NumberOfBottles = int.Parse(txtNoOfBottles.Text),
             BloodBankID     = (txtBloodBankId.Text),
             ExpiryDate      = Convert.ToDateTime(txtExpiryDate.Text),
             //HospitalID = int.Parse(txtHospitalId.Text)
         };
         BloodInventoryBLL pb = new BloodInventoryBLL();
         if (pb.EditBloodInventory(p))
         {
             groupBox.Visibility = Visibility.Hidden;
             MessageBox.Show("Inventory data updated.", "BBMS");
         }
     }
     catch (BloodBankExceptions ex)
     {
         MessageBox.Show(ex.Message, "BBMS");
     }
     catch (SystemException ex)
     {
         MessageBox.Show(ex.Message, "BBMS");
     }
 }
Beispiel #2
0
 private void button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         BloodInventoryBLL pb = new BloodInventoryBLL();
         BloodInventory    p  = pb.Search(int.Parse(SearchtextBox.Text));
         if (p != null)
         {
             BloodGrouptextBox.Text = p.BloodGroup;
             txtBloodBankId.Text    = p.BloodBankID.ToString();
             txtNoOfBottles.Text    = p.NumberOfBottles.ToString();
             txtExpiryDate.Text     = p.ExpiryDate.ToShortDateString();
             // txtHospitalId.Text = p.HospitalID.ToString();
             groupBox.Visibility = Visibility.Visible;
         }
         else
         {
             groupBox.Visibility = Visibility.Hidden;
             MessageBox.Show
                 (string.Format("Blood Inventory with id {0} does not exists.", SearchtextBox.Text),
                 "Blood Inventory Management System");
         }
     }
     catch (BloodBankExceptions ex)
     {
         MessageBox.Show(ex.Message, "Blood Inventory Management System");
     }
     catch (SystemException ex)
     {
         MessageBox.Show(ex.Message, "Blood Inventory Management System");
     }
 }
Beispiel #3
0
 private void checkBloodQuantity(int id)
 {
     this.bloodInventoryTable = db.BloodInventories.SingleOrDefault(x => x.Id == id);
     if (this.bloodInventoryTable != null)
     {
         this.bloodQuantity    = this.bloodInventoryTable.bloodquantity ?? default(int);
         this.LableStatus.Text = this.bloodGroup + " : " + this.bloodQuantity.ToString();
     }
 }
Beispiel #4
0
 public bool EditBloodInventory(BloodInventory pobj)
 {
     try
     {
         BloodInventoryDL pd = new BloodInventoryDL();
         return(pd.EditBloodInventory(pobj));
     }
     catch (BloodBankExceptions)
     {
         throw;
     }
 }
Beispiel #5
0
        public BloodInventory Search(int searchInventory)
        {
            BloodInventory p = null;

            try
            {
                //  con = new SqlConnection();
                //con.ConnectionString = ConfigurationManager.ConnectionStrings["ConStr"].ConnectionString;
                cmd             = new SqlCommand();
                cmd.CommandText = "BBank.uspSearchBloodInventory";
                cmd.Connection  = con;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@bId", searchInventory);

                con.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    dr.Read();
                    p = new BloodInventory
                    {
                        BloodGroup      = dr["BloodGroup"].ToString(),
                        NumberOfBottles = int.Parse(dr["NumberofBottles"].ToString()),
                        BloodBankID     = (dr["BloodBankID"].ToString()),
                        ExpiryDate      = DateTime.Parse((dr["ExpiryDate"].ToString())),
                        // HospitalID = int.Parse(dr["HospitalId"].ToString())
                    };
                    dr.Close();
                }
            }
            catch (BloodBankExceptions) { throw; }
            catch (SqlException)
            {
                throw;
            }
            catch (SystemException)
            {
                throw;
            }
            finally
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }
            return(p);
        }
Beispiel #6
0
        private void addToBloodInventory() //only for donation
        {
            BloodData      bdataTable = db.BloodDatas.SingleOrDefault(x => x.userID == this.LoggedUName);
            BloodInventory bloodTable = db.BloodInventories.SingleOrDefault(x => x.bloodgroup == this.bloodGroup);

            if (bloodTable != null && bdataTable != null)
            {
                this.date = DateTime.Now;
                bloodTable.bloodquantity += 1;
                bdataTable.donated       += 1;
                bdataTable.date           = date.ToString();
                bdataTable.month          = int.Parse(date.Month.ToString());
                db.SubmitChanges();
                this.addToHistory(1);
                this.LableStatus.Text = bloodTable.bloodgroup + " : Blood Donated " + bloodTable.bloodquantity.ToString();
            }
        }
Beispiel #7
0
        public bool EditBloodInventory(BloodInventory pboj)
        {
            bool result = false;

            try
            {
                // con = new SqlConnection();
                //   con.ConnectionString = ConfigurationManager.ConnectionStrings["ConStr"].ConnectionString;
                cmd             = new SqlCommand();
                cmd.CommandText = "BBank.uspEditBloodInventory";
                cmd.Connection  = con;
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@bId", pboj.BloodInvenoryID);
                cmd.Parameters.AddWithValue("@BloodGroup", pboj.BloodGroup);
                cmd.Parameters.AddWithValue("@noofbottle", pboj.NumberOfBottles);
                cmd.Parameters.AddWithValue("@BloodBankId", pboj.BloodBankID);
                cmd.Parameters.AddWithValue("@expiryDate", pboj.ExpiryDate);
                //cmd.Parameters.AddWithValue("@hid", pboj.HospitalID);

                con.Open();
                int noOfRowsAffected = cmd.ExecuteNonQuery();
                if (noOfRowsAffected == 1)
                {
                    result = true;
                }
            }
            catch (BloodBankExceptions) { throw; }
            catch (SqlException)
            {
                throw;
            }
            catch (SystemException)
            {
                throw;
            }
            finally
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }
            return(result);
        }
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (this.checkValidation())
     {
         BloodInventory bloodInvTab = db.BloodInventories.SingleOrDefault(x => x.bloodgroup == this.bloodGroup);
         if (bloodInvTab != null)
         {
             int quantity = int.Parse(this.txtBloodQuantity.Text.ToString());
             bloodInvTab.bloodquantity += quantity;
             db.SubmitChanges();
             this.lableStatus.Text = this.bloodGroup + " : " + bloodInvTab.bloodquantity.ToString() + "Total";
         }
     }
     else
     {
         lableStatus.Text = "Validation Error";
     }
 }
Beispiel #9
0
        private void updateBloodQuantity(int uReqQuantity) //only for request blood
        {
            BloodData      bDataTable    = db.BloodDatas.SingleOrDefault(x => x.userID == this.LoggedUName);
            BloodInventory bloodInvTable = db.BloodInventories.SingleOrDefault(x => x.bloodgroup == this.bloodGroup);

            if (bloodInvTable != null && bDataTable != null)
            {
                this.bloodQuantity -= uReqQuantity;
                //i was here
                bloodInvTable.bloodquantity = this.bloodQuantity;
                //db.SubmitChanges();
                bDataTable.requested += int.Parse(this.txtBloodQuantity.Text.ToString()); //it was not updating
                db.SubmitChanges();
                this.addToHistory(uReqQuantity);
                MessageBox.Show("Request Accepted" + bDataTable.requested.ToString());
            }
            else
            {
                MessageBox.Show("DB not Updated");
            }
        }