public int Insert(Disease aDisease) { string query = "insert into Disease_tbl values ('" + aDisease.Name + "','" + aDisease.Description + "','" + aDisease.Treatment + "')"; SqlConnection aConnection = new SqlConnection(conncetionStr); SqlCommand aCommand = new SqlCommand(query, aConnection); aConnection.Open(); int rowAffect = aCommand.ExecuteNonQuery(); aConnection.Close(); return rowAffect; }
protected void saveButton_Click(object sender, EventArgs e) { Disease aDisease = new Disease(); aDisease.Name = diseaseNameTextBox.Text; aDisease.Description = descriptionTextBox.Text; aDisease.Treatment = treatmentProcedureTextBox.Text; savelable.Text = aDiseaseManager.Insert(aDisease); dieseaseGridView.DataSource = aDiseaseManager.GetAllDisease(); dieseaseGridView.DataBind(); }
public string Insert(Disease aDisease) { if (aDisease.Name == "") { return "Enter a Name"; } else if (aDiseaseGateway.Cheak(aDisease.Name)==true) { return "Already Exist."; } else if (aDiseaseGateway.Insert(aDisease)>0) return "Medicine Saved"; else return "Try Again"; }