private bool UpdateUnit() { try { if (Session["_unit"] == null) { ConfirmAlertBox1.ShowMessage("Session has expired.", ConfirmAlertBox.PopupMessageType.Error); Response.Redirect("~/Login.aspx"); return(false); } var unit = Session["_unit"] as xPlug.BusinessObject.Unit; if (unit == null || unit.UnitId < 1) { ErrorDispManageUnit.ShowError("Session has expired"); Response.Redirect("~/Login.aspx"); return(false); } unit.Name = txtName.Text.Trim(); unit.DepartmentId = int.Parse(ddlDepartment.SelectedValue); unit.Status = chkUnit.Checked ? 1 : 0; var k = ServiceProvider.Instance().GetUnitServices().UpdateUnitCheckDuplicate(unit); if (k < 1) { if (k == -3) { ErrorDispManageUnit.ShowError("Unit already exists."); txtName.Focus(); mpeProcessUnit.Show(); } else { ErrorDispManageUnit.ShowError("Unit information could not be updated."); mpeProcessUnit.Show(); } } return(true); } catch (Exception ex) { ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error); ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message); throw; } }
private bool ValidateControls() { if (string.IsNullOrEmpty(txtName.Text.Trim())) { ErrorDispManageUnit.ShowError("Please enter a Unit."); txtName.Focus(); mpeProcessUnit.Show(); return(false); } if (int.Parse(ddlDepartment.SelectedValue) < 1) { ErrorDispManageUnit.ShowError("Please select a Department."); ddlDepartment.Focus(); mpeProcessUnit.Show(); return(false); } return(true); }
private bool AddUnit() { try { var newUnit = new xPlug.BusinessObject.Unit { Name = txtName.Text.Trim(), DepartmentId = int.Parse(ddlDepartment.SelectedValue), Status = chkUnit.Checked ? 1 : 0 }; var k = ServiceProvider.Instance().GetUnitServices().AddUnitCheckDuplicate(newUnit); if (k < 1) { if (k == -3) { ErrorDispManageUnit.ShowError("Unit Information already exists."); txtName.Focus(); mpeProcessUnit.Show(); return(false); } ErrorDispManageUnit.ShowError("Unit Information could not be added. Please try again later or contact the Administrator."); mpeProcessUnit.Show(); return(false); } ConfirmAlertBox1.ShowSuccessAlert("Unit Information was added to successfully."); return(true); } catch (Exception ex) { ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error); ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message); throw; } }