protected void dgEmployeePosition_DeleteCommand(object source, DataGridCommandEventArgs e) { int id = (int)dgEmployeePosition.DataKeys[e.Item.ItemIndex]; Chai.WorkflowManagment.CoreDomain.Setting.EmployeePosition EmployeePosition = _presenter.GetEmployeePositionById(id); try { EmployeePosition.Status = "InActive"; _presenter.SaveOrUpdateEmployeePosition(EmployeePosition); BindEmployeePosition(); Master.ShowMessage(new AppMessage("Employee Position was Removed Successfully", Chai.WorkflowManagment.Enums.RMessageType.Info)); } catch (Exception ex) { Master.ShowMessage(new AppMessage("Error: Unable to delete Employee Position. " + ex.Message, Chai.WorkflowManagment.Enums.RMessageType.Error)); } }
protected void dgEmployeePosition_UpdateCommand(object source, DataGridCommandEventArgs e) { int id = (int)dgEmployeePosition.DataKeys[e.Item.ItemIndex]; Chai.WorkflowManagment.CoreDomain.Setting.EmployeePosition EmployeePosition = _presenter.GetEmployeePositionById(id); try { TextBox txtName = e.Item.FindControl("txtPositionName") as TextBox; EmployeePosition.PositionName = txtName.Text; SaveEmployeePosition(EmployeePosition); dgEmployeePosition.EditItemIndex = -1; BindEmployeePosition(); } catch (Exception ex) { Master.ShowMessage(new AppMessage("Error: Unable to Update Employee Position. " + ex.Message, Chai.WorkflowManagment.Enums.RMessageType.Error)); } }
protected void dgEmployeePosition_ItemCommand(object source, DataGridCommandEventArgs e) { Chai.WorkflowManagment.CoreDomain.Setting.EmployeePosition EmployeePosition = new Chai.WorkflowManagment.CoreDomain.Setting.EmployeePosition(); if (e.CommandName == "AddNew") { try { TextBox txtFEmployeePositionName = e.Item.FindControl("txtFPositionName") as TextBox; EmployeePosition.PositionName = txtFEmployeePositionName.Text; EmployeePosition.Status = "Active"; SaveEmployeePosition(EmployeePosition); dgEmployeePosition.EditItemIndex = -1; BindEmployeePosition(); } catch (Exception ex) { Master.ShowMessage(new AppMessage("Error: Unable to Add Employee Position " + ex.Message, Chai.WorkflowManagment.Enums.RMessageType.Error)); } } }
private void SaveEmployeePosition(Chai.WorkflowManagment.CoreDomain.Setting.EmployeePosition EmployeePosition) { try { if (EmployeePosition.Id <= 0) { _presenter.SaveOrUpdateEmployeePosition(EmployeePosition); Master.ShowMessage(new AppMessage("Employee Position saved", RMessageType.Info)); //_presenter.CancelPage(); } else { _presenter.SaveOrUpdateEmployeePosition(EmployeePosition); Master.ShowMessage(new AppMessage("Employee Position Updated", RMessageType.Info)); // _presenter.CancelPage(); } } catch (Exception ex) { Master.ShowMessage(new AppMessage(ex.Message, RMessageType.Error)); } }