protected void addButton_Click(object sender, EventArgs e) { Medicine aMedicine = new Medicine(); aMedicine.Name = selectMedicineDropDownList.Text; aMedicine.Id = aMedicineManager.GetMedicineIdByName(aMedicine.Name); int quantity = Convert.ToInt32(quantityTextBox.Text); AddMedicineInQueue(aMedicine.Name, quantity); }
protected void saveButton_Click(object sender, EventArgs e) { Medicine aMedicine = new Medicine(); aMedicine.Name = medicineNameTextBox.Text; saveLabel.Text = aMedicineManager.Insert(aMedicine); medicineGridView.DataSource = aMedicineManager.GetAllMedicine(); medicineGridView.DataBind(); }
public int Insert(Medicine aMedicine) { string query = "insert into medicine_tbl values ('" + aMedicine.Name + "')"; SqlConnection aConnection = new SqlConnection(conncetionStr); SqlCommand aCommand = new SqlCommand(query,aConnection); aConnection.Open(); int rowAffect = aCommand.ExecuteNonQuery(); aConnection.Close(); return rowAffect; }
public string Insert(Medicine aMedicine) { if (aMedicine.Name == "") { return "Enter A name"; } else if (aMedicineGateway.Check(aMedicine.Name) == true) { return "Already Exist"; } else if (aMedicineGateway.Insert(aMedicine) > 0) return "Medicine Saved"; else return "Try Again"; }