protected void cmdSubmit_Click(object sender, EventArgs e) { if (txtName.Text == "") { lblError.Text = "Please enter a Function name."; txtName.Focus(); return; } if (txtCode.Text == "") { lblError.Text = "Please enter a Function code."; txtCode.Focus(); return; } lblError.Text = ""; _currentDepartment = (TimeDepartments)Session["CurrentDepartment"]; if (_currentDepartment == null) { //new department object TimeDepartments department = TimeDepartments.New(); //fill object with data department.DepartmentName = txtName.Text; department.DepartmentCode = txtCode.Text; department.Description = txtDescription.Text; department.Status = 1; department.Type = 1; //save the new department department.Save(); } else { _currentDepartment.DepartmentName = txtName.Text; _currentDepartment.DepartmentCode = txtCode.Text; _currentDepartment.Description = txtDescription.Text; _currentDepartment.Status = 1; _currentDepartment.Type = 1; //save the new department _currentDepartment.Save(); } txtName.Text = ""; txtDescription.Text = ""; txtCode.Text = ""; _currentDepartment = null; Session["CurrentDepartment"] = _currentDepartment; RefreshEntries(); updEntries.Update(); lblSuccessMessage.Text = "Successfully submitted data!"; mpSuccess.Show(); }
protected void rptCustomers_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "Edit") { string allKeys = Convert.ToString(e.CommandArgument); int pkID = Convert.ToInt32(allKeys); _currentDepartment = TimeDepartments.Read(pkID); Session["CurrentDepartment"] = _currentDepartment; txtName.Text = _currentDepartment.DepartmentName; txtCode.Text = _currentDepartment.DepartmentCode; txtDescription.Text = _currentDepartment.Description; } if (e.CommandName == "Delete") { string allKeys = Convert.ToString(e.CommandArgument); int pkID = Convert.ToInt32(allKeys); _currentDepartment = TimeDepartments.Read(pkID); _currentDepartment.Delete(); _currentDepartment = null; Session["CurrentDepartment"] = _currentDepartment; RefreshEntries(); updEntries.Update(); lblSuccessMessage.Text = "Successfully deleted data!"; mpSuccess.Show(); } }