protected void btnSave_Click(object sender, EventArgs e) { string msg = "Route has been saved."; try { TblRoute obj = new TblRoute(); obj.IsNew = true; if (!string.IsNullOrEmpty(hdnRouteID.Value)) { obj = new TblRoute(hdnRouteID.Value); obj.IsNew = false; msg = "Route has been updated."; } obj.RFrom = txtRForm.Text; obj.RTo = txtRTo.Text; obj.BranchID = Convert.ToInt32(Session["BranchID"]); obj.RFare = Convert.ToInt32(txtRFee.Text); obj.IsActive = Convert.ToInt32(ddlstatus.SelectedValue); obj.Save(); lblmsg.Text = helper.DisplayNotificationMessage(msgDiv, msg, "alert alert-success alert-icon alert-dismissible", icon, "icon mdi mdi-check"); helper.ClearInputs(Page.Controls); loadrptRoute(Convert.ToString(Session["BranchID"])); } catch (Exception ex) { msgDiv.Visible = true; lblmsg.Text = helper.DisplayNotificationMessage(msgDiv, ex.ToString(), "alert alert-danger alert-icon alert-dismissible", icon, "icon mdi mdi-close-circle-o"); lblmsg.Text = ex.ToString(); } }
protected void btnEdit_Click(object sender, EventArgs e) { LinkButton btn = (LinkButton)sender; TblRoute obj = new TblRoute(btn.CommandArgument); txtRForm.Text = obj.RFrom.ToString(); txtRTo.Text = obj.RTo.ToString(); txtRFee.Text = obj.RFare.ToString(); ddlstatus.SelectedValue = obj.IsActive.ToString(); hdnRouteID.Value = obj.RouteID.ToString(); ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true); }
private int DeleteTblRoute(TblRoute row) { using (var context = new WorkFlowManagerDBEntities()) { var oldRow = (from e in context.TblRoutes where e.Iserial == row.Iserial select e).SingleOrDefault(); if (oldRow != null) { context.DeleteObject(oldRow); } context.SaveChanges(); } return(row.Iserial); }
public void SaveDetailRow() { if (SelectedDetailRow != null) { var valiationCollection = new List <ValidationResult>(); var isvalid = Validator.TryValidateObject(SelectedDetailRow, new ValidationContext(SelectedDetailRow, null, null), valiationCollection, true); if (isvalid) { var save = SelectedDetailRow.Iserial == 0; var rowToSave = new TblRoute(); rowToSave.InjectFrom(SelectedDetailRow); Client.UpdateOrInsertTblRouteAsync(rowToSave, save, SelectedMainRow.DetailsList.IndexOf(SelectedDetailRow)); } } }
private TblRoute UpdateOrInsertTblRoute(TblRoute newRow, bool save, int index, out int outindex) { outindex = index; using (var context = new WorkFlowManagerDBEntities()) { if (save) { context.TblRoutes.AddObject(newRow); } else { var oldRow = (from e in context.TblRoutes where e.Iserial == newRow.Iserial select e).SingleOrDefault(); if (oldRow != null) { GenericUpdate(oldRow, newRow, context); } } context.SaveChanges(); return(newRow); } }