private void StockSave() { List <CenterMedicineStock> currentStocks = (List <CenterMedicineStock>)ViewState["MedicineStock"]; CenterMedicineStock newMedicineStock = new CenterMedicineStock(); newMedicineStock.MedicineID = int.Parse(medicineDropDownList.SelectedItem.Value); newMedicineStock.Quantity = int.Parse(quantityMedicineTextBox.Text); newMedicineStock.CenterID = int.Parse(centerDropDownList.SelectedItem.Value); currentStocks.Add(newMedicineStock); ViewState["MedicineStock"] = currentStocks; }
public int CenterStockSave(CenterMedicineStock medicine) { string query = "insert into Quantity_tbl(Quantity,CenterID,MedicineID) values('" + medicine.Quantity + "','" + medicine.CenterID + "','" + medicine.MedicineID + "')"; aGateway.sqlConnection.Open(); aGateway.command.CommandText = query; int rowAffected = aGateway.command.ExecuteNonQuery(); aGateway.sqlConnection.Close(); return(rowAffected); }
public List <CenterMedicineStock> GetStock(DAL.DAO.Center newCenter) { List <CenterMedicineStock> listofStock = aCenterGateway.ListofStocks(newCenter); List <CenterMedicineStock> medicineStockWithDetails = new List <CenterMedicineStock>(); foreach (CenterMedicineStock medicineStock in listofStock) { CenterMedicineStock newMedicineStock = new CenterMedicineStock(); newMedicineStock.Quantity = medicineStock.Quantity; newMedicineStock.MedicineName = aCenterGateway.MedicineName(medicineStock.MedicineID); medicineStockWithDetails.Add(newMedicineStock); } return(medicineStockWithDetails); }
public bool IsMedicineExist(CenterMedicineStock medicine, out int quantity) { bool result = false; quantity = 0; aGateway.command.CommandText = "SELECT * FROM Quantity_tbl WHERE CenterID='" + medicine.CenterID + "' AND MedicineID='" + medicine.MedicineID + "'"; aGateway.sqlConnection.Open(); SqlDataReader reader = aGateway.command.ExecuteReader(); while (reader.Read()) { result = true; quantity = int.Parse(reader["Quantity"].ToString()); break; } reader.Close(); aGateway.sqlConnection.Close(); return(result); }
public List <CenterMedicineStock> ListofStocks(DAO.Center aCenter) { List <CenterMedicineStock> stock = new List <CenterMedicineStock>(); aGateway.command.CommandText = "SELECT * FROM Quantity_tbl WHERE CenterID='" + aCenter.ID + "'"; aGateway.sqlConnection.Open(); SqlDataReader reader = aGateway.command.ExecuteReader(); while (reader.Read()) { CenterMedicineStock newMedicine = new CenterMedicineStock(); newMedicine.Quantity = int.Parse(reader[1].ToString()); newMedicine.MedicineID = int.Parse(reader[3].ToString()); stock.Add(newMedicine); } reader.Close(); aGateway.sqlConnection.Close(); return(stock); }