Example #1
0
        private void SaveHREmployeeLeaveApplicationEntity()
        {
            if (ValidationInput())
            {
                if (IsValid)
                {
                    try
                    {
                        HREmployeeLeaveApplicationEntity hREmployeeLeaveApplicationEntity = BuildHREmployeeLeaveApplicationEntity();

                        hREmployeeLeaveApplicationEntity.SalarySessionID = Int64.Parse(ViewState["SalarySessionID"].ToString());



                        Int64 result = -1;
                        if (hREmployeeLeaveApplicationEntity.IsNew)
                        {
                            result = FCCHREmployeeLeaveApplication.GetFacadeCreate().Add(hREmployeeLeaveApplicationEntity, DatabaseOperationType.Add, TransactionRequired.No);
                            if (hREmployeeLeaveApplicationEntity.BackupEmployeeID != null)
                            {
                                SendMail(hREmployeeLeaveApplicationEntity);
                            }
                        }
                        else
                        {
                            String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(HREmployeeLeaveApplicationEntity.FLD_NAME_EmployeeLeaveApplicationID, hREmployeeLeaveApplicationEntity.EmployeeLeaveApplicationID.ToString(), SQLMatchType.Equal);
                            result = FCCHREmployeeLeaveApplication.GetFacadeCreate().Update(hREmployeeLeaveApplicationEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                        }

                        if (result > 0)
                        {
                            if (hREmployeeLeaveApplicationEntity.IsNew)
                            {
                                #region Approval Process

                                if (ddlAPPanelID != null && ddlAPPanelID.SelectedValue != "0")
                                {
                                    Boolean apResult = APRobot.CreateApprovalProcessForNewLeaveApplication(result, Int64.Parse(ddlAPPanelID.SelectedValue.ToString()));
                                    if (apResult == true)
                                    {
                                        MiscUtil.ShowMessage(lblMessage, "Approval Process Submited successfully.", UIConstants.MessageType.GREEN);
                                    }
                                    else
                                    {
                                        MiscUtil.ShowMessage(lblMessage, "Failed to Submit Approval Process.", UIConstants.MessageType.RED);
                                    }
                                }
                            }

                            #endregion

                            _EmployeeLeaveApplicationID       = 0;
                            _HREmployeeLeaveApplicationEntity = new HREmployeeLeaveApplicationEntity();
                            PrepareInitialView();
                            BindHREmployeeLeaveApplicationList();

                            if (hREmployeeLeaveApplicationEntity.IsNew)
                            {
                                MiscUtil.ShowMessage(lblMessage, "Employee Leave Application Information has been added successfully.", false);
                            }
                            else
                            {
                                MiscUtil.ShowMessage(lblMessage, "Employee Leave Application Information has been updated successfully.", false);
                            }
                        }
                        else
                        {
                            if (hREmployeeLeaveApplicationEntity.IsNew)
                            {
                                MiscUtil.ShowMessage(lblMessage, "Failed to add Employee Leave Application Information.", false);
                            }
                            else
                            {
                                MiscUtil.ShowMessage(lblMessage, "Failed to update Employee Leave Application Information.", false);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }