protected void btnSave_Click(object sender, EventArgs e) { try { ListTable myListTable = new ListTable(); List<ListTable> aList = myListTable.GetAllListTable(_company.CompanyId); ListTable tempListTable = aList[aList.Count - 1]; int id = tempListTable.Id + 1; myListTable.ListType = txtListType.Value; myListTable.ListId = id ; myListTable.ListValue = txtListValue.Value; myListTable.CompanyId = _company.CompanyId; myListTable.IsActive = true; myListTable.UpdateBy = _user.UserId; myListTable.UpdateDate = DateTime.Now; int sucess = 0; if (lblId.Text == "" || lblId.Text == "0") { myListTable.Id = new ListTable().GetMaxListTableId() + 1; sucess = myListTable.InsertListTable(); if (sucess > 0) { Alert.Show("List Table saved successfully"); this.Clear(); } } else { myListTable.Id = int.Parse(lblId.Text); sucess = myListTable.UpdateListTable(); if (sucess > 0) { Response.Redirect("ListTableLists.aspx", true); } } } catch (Exception exp) { Alert.Show(exp.Message); } }
protected void btnSave_Click(object sender, EventArgs e) { try { ListTable myListTable = new ListTable(); List<ListTable> aList = myListTable.GetAllListTable(_company.CompanyId); ListTable tempListTable = aList[aList.Count - 1]; int id = tempListTable.Id + 1; myListTable.ListType = txtListType.Value; myListTable.ListId = id ; myListTable.ListValue = txtListValue.Value; myListTable.CompanyId = _company.CompanyId; myListTable.IsActive = true; myListTable.UpdateBy = user.UserId; myListTable.UpdateDate = DateTime.Now; int success = myListTable.InsertListTable(); if (success > 0) { Session["savedListMessage"] = "Saved List Table Successfully"; Response.Redirect(Request.RawUrl); } else { Alert.Show("Error Occured while inserting a new List Table"); } } catch (Exception exp) { Alert.Show(exp.Message); } }