public int UpdateData(Objects.Medicine med) { int vCheck; // string vQuery = "Insert into Medicine(Med_ID,Medicine_Name,Expiry_Time,Formula ,Manufacturer ,Type_ID,Symptom_ID, Quantity, Price) " + // "Values ('" + GetMaxID() + "','" + med.MedName + "','" + med.ExpTime + "','" + med.Formula + "','" // + med.Manufacturer + "'," + med.TypeID + "," + med.SymptomID + "," + med.Quantity + "," + med.Price + ")"; string vQuery = "UPDATE Medicine SET Medicine_Name = '" + med.MedName + "', Expiry_Time = '" + med.ExpTime + "', Formula = '" + med.Formula + "', Manufacturer = '" + med.Manufacturer + "', Type_ID = " + med.TypeID + ", Symptom_ID = " + med.SymptomID + ", Quantity = " + med.Quantity + ", Price = " + med.Price + " WHERE Medicine_Name = '" + med.MedName + "'"; Conn = new SqlConnection(connectionString); command = new SqlCommand(vQuery, Conn); try { Conn.Open(); vCheck = command.ExecuteNonQuery(); } catch (Exception ex) { throw ex; } finally { Conn.Close(); } return(vCheck); }
public DataTable formloadName(Objects.Medicine med, string name) { string vQuery = "Select Medicine_Name, Expiry_Time, Formula, Manufacturer, Quantity, Price," + "Type.Type, Symptom.Symptom From Medicine INNER JOIN Type ON Type.Type_ID = Medicine.Type_ID " + "INNER JOIN Symptom ON Symptom.Symptom_ID = Medicine.Symptom_ID where Medicine_Name LIKE '%" + name + "%'"; dt = new DataTable(); Conn = new SqlConnection(connectionString); command = new SqlCommand(vQuery, Conn); med = new Objects.Medicine(); try { Conn.Open(); adapter = new SqlDataAdapter(command); adapter.Fill(dt); } catch (Exception ex) { throw ex; } finally { Conn.Close(); } return(dt); }
private void UpdateBtn(object sender, RoutedEventArgs e) { if (checkIfEmpty()) { Objects.Medicine Obj = new Objects.Medicine(); //Obj.MedID = new BLL.Medicine().GetMaxID(); Obj.MedName = txtMedName.Text.ToString(); Obj.Formula = txtFormula.Text.ToString(); Obj.ExpTime = txtExpiry.Text.ToString(); Obj.TypeID = new BLL.Medicine().GetTypeID(TypeComboBox.Text.ToString()); Obj.SymptomID = new BLL.Medicine().GetUseID(UseComboBox.Text.ToString()); Obj.Manufacturer = txtManufacturer.Text.ToString(); Obj.Quantity = Convert.ToInt32(txtQuantity.Text); Obj.Price = Convert.ToInt32(txtPrice.Text); int vCheck = new BLL.Medicine().UpdateData(Obj); MessageBox.Show("Data Updated"); txtExpiry.Text = ""; txtQuantity.Text = ""; txtManufacturer.Text = ""; txtPrice.Text = ""; txtFormula.Text = ""; txtMedName.Text = ""; TypeComboBox.SelectedIndex = -1; UseComboBox.SelectedIndex = -1; Close(); } else { MessageBox.Show("Please Fill All The Inputs."); } }
private void SymptomBtn(object sender, RoutedEventArgs e) { Objects.Medicine Obj = new Objects.Medicine(); DataTable dt = new DataTable(); dt = new BLL.Medicine().formloadSymptom(Obj, Search_Symptom.Text.ToString()); MedicineGrid.ItemsSource = dt.AsDataView(); clearAll(); }
private void FillForm(Objects.Medicine med) { txtMedName.Text = med.MedName; txtManufacturer.Text = med.Manufacturer; txtQuantity.Text = med.Quantity.ToString(); txtPrice.Text = med.Price.ToString(); txtFormula.Text = med.Formula.ToString(); txtExpiry.Text = med.ExpTime.ToString(); TypeComboBox.SelectedIndex = med.TypeID - 1; UseComboBox.SelectedIndex = med.SymptomID - 1; }
private void NameBtn(object sender, RoutedEventArgs e) { Objects.Medicine Obj = new Objects.Medicine(); DataTable dt = new DataTable(); dt = new BLL.Medicine().formloadName(Obj, Search_Name.Text); MedicineGrid.ItemsSource = dt.AsDataView(); clearAll(); }
private void formload() { counter = 1; txtQuantity.Text = counter.ToString(); Objects.Medicine Obj = new Objects.Medicine(); DataTable dt = new DataTable(); dt = new BLL.Medicine().formload(Obj); MedicineGrid.ItemsSource = dt.AsDataView(); }
private void MedicineGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (MedicineGrid.SelectedIndex != -1) { BLL.Medicine Obj = new BLL.Medicine(); Objects.Medicine med = new Objects.Medicine(); string MedName; DataRowView rows = (DataRowView)MedicineGrid.SelectedItems[0]; MedName = rows["Medicine_Name"].ToString(); med = Obj.getRow(MedName); new UpdateWindow(med).Show(); } else { MessageBox.Show("Please select an entry from the table."); } }
public Objects.Medicine getRow(string Medicine) { Objects.Medicine med = new Objects.Medicine(); string vQuery = "Select * from Medicine WHERE Medicine_Name = '" + Medicine + "'"; Conn = new SqlConnection(connectionString); command = new SqlCommand(vQuery, Conn); SqlDataReader dr; try { Conn.Open(); dr = command.ExecuteReader(); if (dr.Read()) { med.MedID = Convert.ToInt32(dr["Med_ID"].ToString()); med.MedName = dr["Medicine_Name"].ToString(); med.ExpTime = dr["Expiry_Time"].ToString(); med.Formula = dr["Formula"].ToString(); med.Manufacturer = dr["Manufacturer"].ToString(); med.Quantity = Convert.ToInt32(dr["Quantity"].ToString()); med.Price = Convert.ToInt32(dr["Price"].ToString()); med.TypeID = Convert.ToInt32(dr["Type_ID"].ToString()); med.SymptomID = Convert.ToInt32(dr["Symptom_ID"].ToString()); } } catch (Exception e) { throw e; } finally { Conn.Close(); } return(med); }
public int InsertData(Objects.Medicine med) { return(new DAL.Medicine().InsertData(med)); }
public UpdateWindow(Objects.Medicine med) { InitializeComponent(); fillCombo(); FillForm(med); }
public DataTable formloadFormula(Objects.Medicine med, string formula) { return(new DAL.Medicine().formloadFormula(med, formula)); }
public DataTable formloadName(Objects.Medicine med, string name) { return(new DAL.Medicine().formloadName(med, name)); }
public DataTable formloadManufacturer(Objects.Medicine med, string manufacturer) { return(new DAL.Medicine().formloadManufacturer(med, manufacturer)); }
public DataTable formloadSymptom(Objects.Medicine med, string symptom) { return(new DAL.Medicine().formloadSymptom(med, symptom)); }
public int UpdateData(Objects.Medicine med) { return(new DAL.Medicine().UpdateData(med)); }
public DataTable formload(Objects.Medicine med) { return(new DAL.Medicine().formload(med)); }