public DataTable GetByGarageID(Garage_ML ml) { DataTable dt = new DataTable(); try { con = new SqlConnection(connectionString); con.Open(); cmd = new SqlCommand("sp_GetGarageByID", con) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("@GarageID", ml.GarageID); adp = new SqlDataAdapter(cmd); adp.Fill(dt); return dt; } catch (SqlException ex) { return dt; } finally { con.Close(); con.Dispose(); } return dt; }
public DataTable GetGarageData(Garage_ML ml) { try { var DataDic = new Dictionary<string, object> { {"@location", ml.GarageLocation} }; return new DBAccessController().RetriveRecordsWithPara(StoredProcedures.sp_GetGarageDetails, DataDic); } catch { throw; } }
public bool DeleteGarage(Garage_ML ml) { try { var DataDic = new Dictionary<string, object> { {"@GarageID", ml.GarageID} }; return new DBAccessController().DeleteRecord(StoredProcedures.sp_RemoveGarage, DataDic); } catch (System.Exception) { throw; } }
private void GetGarageData() { try { var ml = new Garage_ML(); { ml.GarageLocation = string.IsNullOrEmpty(txtLocationSearch.Text) ? "" : txtLocationSearch.Text; }; gridGarages.DataSource = new Garage_BL().GetGarageData(ml); gridGarages.DataBind(); } catch (Exception) { throw; } }
public bool AddGarage(Garage_ML ml) { try { var DataDic = new Dictionary<string, object> { {"@GarageName", ml.GarageName}, {"@GarageLocation",ml.GarageLocation}, {"@GarageTP",ml.GarageTP}, {"@Email",ml.Email} }; return new DBAccessController().InsertRecord(StoredProcedures.sp_AddGarage, DataDic); } catch (System.Exception) { throw; } }
public bool UpdateGarage(Garage_ML ml) { try { var DataDic = new Dictionary<string, object> { {"@Id", ml.GarageID}, {"@GarageName", ml.GarageName}, {"@GarageLocation",ml.GarageLocation}, {"@GarageTP",ml.GarageTP}, {"@Email",ml.Email} }; return new DBAccessController().UpdateRecord(StoredProcedures.sp_UpdateGarage, DataDic); } catch (Exception) { throw; } }
public Boolean RemoveGarage(Garage_ML ml) { try { con = new SqlConnection(connectionString); con.Open(); cmd = new SqlCommand("sp_RemoveGarage", con) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("@GarageID", ml.GarageID); cmd.ExecuteNonQuery(); return true; } catch (SqlException ex) { return false; } finally { con.Close(); con.Dispose(); } }
protected void btnSave_ServerClick(object sender, EventArgs e) { try { var ml = new Garage_ML() { GarageName = txtName.Text, GarageTP = txtTp.Text, GarageLocation = txtLocation.Text, Email = txtEmail.Text }; var result = new Garage_BL().AddGarage(ml); if (result) { GetGarageData(); } } catch (Exception) { throw; } }
protected void btnDelete_ServerClick(object sender, EventArgs e) { try { if (gridGarages.Selection.Count > 0) { var id = (Int32)gridGarages.GetSelectedFieldValues("GarageID")[0]; var ml = new Garage_ML() { GarageID = id }; new Garage_BL().DeleteGarage(ml); GetGarageData(); } else { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "script", "<script type='text/javascript'>$( document ).ready(function() { $('#SelectErrorModal').modal('show')});</script>", false); } } catch (Exception) { throw; } }
protected void btnUpdate_ServerClick(object sender, EventArgs e) { try { var ml = new Garage_ML(gridGarages.GetSelectedFieldValues("GarageID")[0].ToString(), txtLocation.Text, txtName.Text, txtTp.Text, txtEmail.Text); var result = new Garage_BL().UpdateGarage(ml); if (result) { GetGarageData(); } } catch (Exception) { throw; } }
public string GetGarageInfo(Garage_ML ml) { DataTable dt = new DataTable(); try { con = new SqlConnection(connectionString); con.Open(); cmd = new SqlCommand("sp_GetGarageDetails", con) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("@Location", ml.GarageLocation); adp = new SqlDataAdapter(cmd); adp.Fill(dt); string json = JsonConvert.SerializeObject(dt, Formatting.Indented); return json; } catch (SqlException ex) { return "Fail"; } finally { con.Close(); con.Dispose(); } }