protected internal void LoadCharge(object sender, EventArgs e) { int ChargeID = -1; int.TryParse(((LinkButton)sender).CommandArgument, out ChargeID); thisCharge = Charge.Get(ChargeID); //BindData(); LoadHeader(); }
protected internal void SaveCharge(object sender, EventArgs e) { int chargeID = int.Parse(ChargeID.Text); thisCharge = Charge.Get(chargeID); thisCharge.UORCode = UOR_Code.Text; thisCharge.Description = Description.Text; thisCharge.UpdateUOR(); ChargeUpdatedPanel.CssClass += " visible"; Response.Redirect(Request.Url.AbsoluteUri); }
public static Charge Get(int id) { string dsn = ConfigurationManager.ConnectionStrings["RJLouEntities"].ToString(); string sql = @" SELECT * FROM Charge WHERE Charge_ID = @ID"; using (SqlConnection conn = new SqlConnection(dsn)) { conn.Open(); SqlCommand cmd = new SqlCommand(sql, conn); cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("ID", id); SqlDataReader read = cmd.ExecuteReader(); if (read.Read()) { Charge result = new Charge() { ChargeID = Convert.ToInt32(read["Charge_ID"]), UORCode = read["UOR_Code"].ToString(), Description = read["Description"].ToString(), }; return result; } } return null; }
internal void DeleteCharge(Charge charge) { string sql = @" DELETE FROM Case_Charge WHERE Case_ID = @CaseID AND Charge_ID = @ChargeID"; using (SqlConnection conn = new SqlConnection(Constants.DSN)) { conn.Open(); SqlCommand cmd = new SqlCommand(sql, conn); cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("CaseID", CaseID); cmd.Parameters.AddWithValue("ChargeID", charge.ChargeID); cmd.ExecuteNonQuery(); } }
internal void AddCharge(Charge charge) { string sql = @" INSERT INTO Case_Charge (Case_ID, Charge_ID) VALUES (@CaseID, @ChargeID)"; using (SqlConnection conn = new SqlConnection(Constants.DSN)) { conn.Open(); SqlCommand cmd = new SqlCommand(sql, conn); cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("CaseID", CaseID); cmd.Parameters.AddWithValue("ChargeID", charge.ChargeID); cmd.ExecuteNonQuery(); } }