public ActionResult ReadEmployeeSchemeFund(string ESF_Id)
 {
     try
     {
         return(this.Store(WithdrawalRepo.GetESFList(ESF_Id)));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public ActionResult PayTaxRecord(Remit_WithdrawalRepo WithdrawalRepo)
        {
            try
            {
                if (string.IsNullOrEmpty(WithdrawalRepo.Withdrawal_No))
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Sorry! No Benefit has been selected for Payment.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.ERROR,
                        Width   = 350
                    });
                    return(this.Direct());
                }

                if (string.IsNullOrEmpty(WithdrawalRepo.GL_Account_No))
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Please select Bank Account.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.ERROR,
                        Width   = 350
                    });
                    return(this.Direct());
                }


                WithdrawalRepo.GetESFList(WithdrawalRepo.ESF_Id);

                //get GL balance from GL_Account Table
                WithdrawalRepo.Get_GL_Balance(WithdrawalRepo);

                if (WithdrawalRepo.Tax > WithdrawalRepo.GL_Balance * -1)
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Sorry! Insufficient Account Balance.Process aborted.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.ERROR,
                        Width   = 350
                    });
                    return(this.Direct());
                }



                if (string.IsNullOrEmpty(WithdrawalRepo.Payment_Mode))
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Payment Mode is required",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.ERROR,
                        Width   = 350
                    });
                    return(this.Direct());
                }

                //if (WithdrawalRepo.Payment_Mode != "CASH" && string.IsNullOrEmpty(WithdrawalRepo.Instrument_No))
                //{
                //    X.Msg.Show(new MessageBoxConfig
                //    {
                //        Title = "Error",
                //        Message = "Instrument Numebr is required.",
                //        Buttons = MessageBox.Button.OK,
                //        Icon = MessageBox.Icon.INFO,
                //        Width = 350
                //    });

                //    return this.Direct();
                //}

                if (!WithdrawalRepo.Pay_Date_Benefit.HasValue)
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Payment Date is required",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });

                    return(this.Direct());
                }

                // validate scheme date
                if (!string.IsNullOrEmpty(WithdrawalRepo.Scheme_Id))
                {
                    GlobalValue.Get_Scheme_Today_Date(WithdrawalRepo.Scheme_Id);
                    if (WithdrawalRepo.Pay_Date_Benefit != GlobalValue.Scheme_Today_Date)
                    {
                        X.Msg.Show(new MessageBoxConfig
                        {
                            Title   = "Error",
                            Message = "Sorry! Payment date must be equal to scheme working date ",
                            Buttons = MessageBox.Button.OK,
                            Icon    = MessageBox.Icon.INFO,
                            Width   = 350
                        });

                        return(this.Direct());
                    }
                }
                else
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Employee account cannot be verified.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });
                }

                ///pay pending tax

                WithdrawalRepo.PayTax_Unit_Withdrawal(WithdrawalRepo);

                X.Msg.Show(new MessageBoxConfig
                {
                    Title   = "Success",
                    Message = "Benefit Tax Successfully Paid.",
                    Buttons = MessageBox.Button.OK,
                    Icon    = MessageBox.Icon.INFO,
                    Width   = 350
                });
                //ClearControls_PayTax();
                //Store store = X.GetCmp<Store>("PayTaxRequestWithStore");
                //store.Reload();

                //return this.Direct();
                var pvr = new Ext.Net.MVC.PartialViewResult
                {
                    ViewName    = "WithdrawalPayTaxPartial",
                    ContainerId = "MainArea",
                    RenderMode  = RenderMode.AddTo,
                };
                this.GetCmp <TabPanel>("MainArea").SetLastTabAsActive();
                return(pvr);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public ActionResult DApproveRecord(Remit_WithdrawalRepo WithdrawalRepo)
        {
            try
            {
                if (WithdrawalRepo.Withdrawal_No == string.Empty)
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Sorry! No Request has been selected for approval.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.ERROR,
                        Width   = 350
                    });
                    return(this.Direct());
                }


                WithdrawalRepo.GetESFList(WithdrawalRepo.ESF_Id);

                //WithdrawalRepo.Total_Withdrawal_Unit = Math.Round(WithdrawalRepo.Total_Withdrawal_Unit, 4);
                //WithdrawalRepo.Total_Unit_Balance = Math.Round(WithdrawalRepo.Total_Unit_Balance, 4);

                //if (WithdrawalRepo.Total_Withdrawal_Unit > WithdrawalRepo.Total_Unit_Balance)
                //{
                //    X.Msg.Show(new MessageBoxConfig
                //    {
                //        Title = "Error",
                //        Message = "Sorry!Total Withdrawal(Unit) can not be more than Total Unit.",
                //        Buttons = MessageBox.Button.OK,
                //        Icon = MessageBox.Icon.INFO,
                //        Width = 350
                //    });

                //    return this.Direct();
                //}


                ///approve pending withdrawal

                WithdrawalRepo.DApprove_Unit_Withdrawal(WithdrawalRepo);

                X.Msg.Show(new MessageBoxConfig
                {
                    Title   = "Success",
                    Message = "Benefit Request Successfully Disapproved.",
                    Buttons = MessageBox.Button.OK,
                    Icon    = MessageBox.Icon.INFO,
                    Width   = 350
                });
                //ClearControls_Approve();
                //Store store = X.GetCmp<Store>("ApproveRequestWithStore");
                //store.Reload();

                //return this.Direct();
                var pvr = new Ext.Net.MVC.PartialViewResult
                {
                    ViewName    = "WithdrawalApprovePartial",
                    ContainerId = "MainArea",
                    RenderMode  = RenderMode.AddTo,
                };
                this.GetCmp <TabPanel>("MianArea").SetLastTabAsActive();
                return(pvr);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        //public ActionResult AddReversePurchaseTab(string containerId = "MainArea")
        //{
        //    var pvr = new Ext.Net.MVC.PartialViewResult
        //    {
        //        ViewName = "ReversePurchasePartial",
        //        ContainerId = containerId,
        //        RenderMode = RenderMode.AddTo,
        //    };
        //    this.GetCmp<TabPanel>(containerId).SetLastTabAsActive();
        //    return pvr;
        //}


        public ActionResult SaveRecord(Remit_WithdrawalRepo WithdrawalRepo)
        {
            try
            {
                if (!WithdrawalRepo.Trans_Request_Date.HasValue)
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Actual Request Date is a required field",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });

                    return(this.Direct());
                }

                //if (string.IsNullOrEmpty(WithdrawalRepo.Type))
                //{
                //    X.Msg.Show(new MessageBoxConfig
                //    {
                //        Title = "Error",
                //        Message = "'Amount / Unit' is a required field",
                //        Buttons = MessageBox.Button.OK,
                //        Icon = MessageBox.Icon.INFO,
                //        Width = 350
                //    });

                //    return this.Direct();
                //}


                if (string.IsNullOrEmpty(WithdrawalRepo.Withdrawal_Reason))
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Withdrawal Reason is a required field",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });

                    return(this.Direct());
                }


                //check if unit will move to employer
                if (this.GetCmp <Checkbox>("frmWD_Suspense").Checked == true)
                {
                    WithdrawalRepo.Total_Withdrawal_Amount = Math.Round(WithdrawalRepo.Total_Withdrawal_Temp * WithdrawalRepo.Unit_Price, 2);
                    WithdrawalRepo.Total_Withdrawal_Unit   = WithdrawalRepo.Total_Withdrawal_Temp;
                    WithdrawalRepo.To_Employer             = Math.Round(WithdrawalRepo.Total_Unit_Balance - WithdrawalRepo.Total_Withdrawal_Unit, 4);
                }
                else
                {
                    WithdrawalRepo.Total_Withdrawal_Amount = Math.Round(WithdrawalRepo.Total_Withdrawal_Temp * WithdrawalRepo.Unit_Price, 2);
                    WithdrawalRepo.Total_Withdrawal_Unit   = WithdrawalRepo.Total_Withdrawal_Temp;
                    WithdrawalRepo.To_Employer             = 0;
                }



                // check if there is a pending request for the employee scheme fund

                if (WithdrawalRepo.GetcheckESFList(WithdrawalRepo) == true)
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Sorry! There is already a pending request for the Employee Account",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });

                    return(this.Direct());
                }

                // validate scheme date
                if (!string.IsNullOrEmpty(WithdrawalRepo.Scheme_Id))
                {
                    GlobalValue.Get_Scheme_Today_Date(WithdrawalRepo.Scheme_Id);
                    if (WithdrawalRepo.Trans_Request_Date > GlobalValue.Scheme_Today_Date)
                    {
                        X.Msg.Show(new MessageBoxConfig
                        {
                            Title   = "Error",
                            Message = "Sorry! Request date can not be above the scheme working date ",
                            Buttons = MessageBox.Button.OK,
                            Icon    = MessageBox.Icon.INFO,
                            Width   = 350
                        });

                        return(this.Direct());
                    }
                }
                else
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Employee account cannot be verified.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });
                }

                WithdrawalRepo.GetESFList(WithdrawalRepo.ESF_Id);

                WithdrawalRepo.Total_Withdrawal_Unit = Math.Round(WithdrawalRepo.Total_Withdrawal_Unit, 4);
                WithdrawalRepo.Total_Unit_Balance    = Math.Round(WithdrawalRepo.Total_Unit_Balance, 4);

                if (WithdrawalRepo.Total_Withdrawal_Unit > WithdrawalRepo.Total_Unit_Balance)
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Sorry!Total Withdrawal(Unit) can not be more than Total Unit",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });

                    return(this.Direct());
                }


                if (ModelState.IsValid)
                {
                    this.WithdrawalRepo.SaveRecord(WithdrawalRepo);

                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Success",
                        Message = "Withdrawal Successfully Processed.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });
                    // ClearControls();
                    //Store store = X.GetCmp<Store>("WithdrawalESFStore");
                    //store.Reload();
                    //return this.Direct();
                    var pvr = new Ext.Net.MVC.PartialViewResult
                    {
                        ViewName    = "WithdrawalPartial",
                        ContainerId = "MainArea",
                        RenderMode  = RenderMode.AddTo,
                    };
                    this.GetCmp <TabPanel>("MainArea").SetLastTabAsActive();
                    return(pvr);
                }
                else
                {
                    string messages = string.Join(Environment.NewLine, ModelState.Values
                                                  .SelectMany(x => x.Errors)
                                                  .Select(x => x.ErrorMessage));
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = messages, // " Insufficient data. Operation Aborted",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.ERROR,
                        Width   = 350
                    });
                    return(this.Direct());
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        //public ActionResult AddReversePurchaseTab(string containerId = "MainArea")
        //{
        //    var pvr = new Ext.Net.MVC.PartialViewResult
        //    {
        //        ViewName = "ReversePurchasePartial",
        //        ContainerId = containerId,
        //        RenderMode = RenderMode.AddTo,
        //    };
        //    this.GetCmp<TabPanel>(containerId).SetLastTabAsActive();
        //    return pvr;
        //}


        public ActionResult SaveRecord(Remit_WithdrawalRepo WithdrawalRepo, Remit_ReceiptRepo ReceiptRepo)
        {
            try
            {
                if (string.IsNullOrEmpty(ReceiptRepo.ES_Id))
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Please select Employer Account",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });

                    return(this.Direct());
                }

                if (string.IsNullOrEmpty(WithdrawalRepo.GL_Account_No))
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Please select Bank Account",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });

                    return(this.Direct());
                }

                if (!WithdrawalRepo.Trans_Request_Date.HasValue)
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Actual Request Date is a required field",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });

                    return(this.Direct());
                }



                if (string.IsNullOrEmpty(WithdrawalRepo.Withdrawal_Reason))
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Withdrawal Reason is a required field",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });

                    return(this.Direct());
                }


                // check if there is a pending request for the employee scheme fund

                if (WithdrawalRepo.GetcheckESFListEmp(WithdrawalRepo) == true)
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Sorry! There is already a pending request for the Employee Account",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });

                    return(this.Direct());
                }

                // validate scheme date
                if (!string.IsNullOrEmpty(WithdrawalRepo.Scheme_Id))
                {
                    GlobalValue.Get_Scheme_Today_Date(WithdrawalRepo.Scheme_Id);
                    if (WithdrawalRepo.Trans_Request_Date != GlobalValue.Scheme_Today_Date)
                    {
                        X.Msg.Show(new MessageBoxConfig
                        {
                            Title   = "Error",
                            Message = "Sorry! Request date must be equal to scheme working date ",
                            Buttons = MessageBox.Button.OK,
                            Icon    = MessageBox.Icon.INFO,
                            Width   = 350
                        });

                        return(this.Direct());
                    }
                }
                else
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Employee account cannot be verified.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });
                }

                ////get GL balance from GL_Account Table
                //WithdrawalRepo.Get_GL_Balance(WithdrawalRepo);

                //if (WithdrawalRepo.Total_Withdrawal_Amount > WithdrawalRepo.GL_Balance * -1)
                //{
                //    X.Msg.Show(new MessageBoxConfig
                //    {
                //        Title = "Error",
                //        Message = "Sorry! Insufficient Account Balance.Process aborted.",
                //        Buttons = MessageBox.Button.OK,
                //        Icon = MessageBox.Icon.ERROR,
                //        Width = 350
                //    });
                //    return this.Direct();
                //}

                WithdrawalRepo.GetESFList(WithdrawalRepo.ESF_Id);

                WithdrawalRepo.Total_Withdrawal_Unit = Math.Round(WithdrawalRepo.Total_Withdrawal_Unit, 4);
                WithdrawalRepo.Total_Unit_Balance    = Math.Round(WithdrawalRepo.Total_Unit_Balance, 4);

                if (WithdrawalRepo.Total_Withdrawal_Unit > WithdrawalRepo.Total_Unit_Balance)
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Sorry!Total Withdrawal(Unit) can not be more than Total Unit",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });

                    return(this.Direct());
                }


                //if (ModelState.IsValid)
                //{
                this.WithdrawalRepo.SaveRecord_TE(WithdrawalRepo);

                X.Msg.Show(new MessageBoxConfig
                {
                    Title   = "Success",
                    Message = "Benefit Transfer Successfully Processed.",
                    Buttons = MessageBox.Button.OK,
                    Icon    = MessageBox.Icon.INFO,
                    Width   = 350
                });
                // ClearControls();
                //Store store = X.GetCmp<Store>("WithdrawalESFStore");
                //store.Reload();
                //return this.Direct();
                var pvr = new Ext.Net.MVC.PartialViewResult
                {
                    ViewName    = "WithdrawalPartial",
                    ContainerId = "MainArea",
                    RenderMode  = RenderMode.AddTo,
                };
                this.GetCmp <TabPanel>("MainArea").SetLastTabAsActive();
                return(pvr);
                //}
                //else
                //{
                //    string messages = string.Join(Environment.NewLine, ModelState.Values
                //                       .SelectMany(x => x.Errors)
                //                       .Select(x => x.ErrorMessage));
                //    X.Msg.Show(new MessageBoxConfig
                //    {
                //        Title = "Error",
                //        Message = messages, // " Insufficient data. Operation Aborted",
                //        Buttons = MessageBox.Button.OK,
                //        Icon = MessageBox.Icon.ERROR,
                //        Width = 350
                //    });
                //    return this.Direct();
                //}
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public ActionResult ReverseRecord(Remit_WithdrawalRepo WithdrawalRepo)
        {
            try
            {
                if (WithdrawalRepo.Withdrawal_No == string.Empty)
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Sorry! No Port In has been selected for reversal.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.ERROR,
                        Width   = 350
                    });
                    return(this.Direct());
                }

                if (string.IsNullOrEmpty(WithdrawalRepo.Reverse_Reason))
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Reversal Reason is required.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.ERROR,
                        Width   = 350
                    });
                    return(this.Direct());
                }

                WithdrawalRepo.GetESFList(WithdrawalRepo.ESF_Id);

                GlobalValue.Get_Scheme_Today_Date(WithdrawalRepo.Scheme_Id);

                //// validate scheme date
                //if (!string.IsNullOrEmpty(WithdrawalRepo.Scheme_Id))
                //{
                //    GlobalValue.Get_Scheme_Today_Date(WithdrawalRepo.Scheme_Id);
                //    if (WithdrawalRepo.Trans_Date != GlobalValue.Scheme_Today_Date)
                //    {
                //        X.Msg.Show(new MessageBoxConfig
                //        {
                //            Title = "Error",
                //            Message = "Sorry! This transaction can not be reversed. Process aborted",
                //            Buttons = MessageBox.Button.OK,
                //            Icon = MessageBox.Icon.INFO,
                //            Width = 350

                //        });

                //        return this.Direct();
                //    }
                //}
                //else
                //{
                //    X.Msg.Show(new MessageBoxConfig
                //    {
                //        Title = "Error",
                //        Message = "Employee account cannot be verified.",
                //        Buttons = MessageBox.Button.OK,
                //        Icon = MessageBox.Icon.INFO,
                //        Width = 350

                //    });
                //}
                ///reverse port in

                WithdrawalRepo.Reverse_Unit_PortIn(WithdrawalRepo);

                X.Msg.Show(new MessageBoxConfig
                {
                    Title   = "Success",
                    Message = "Porting In Successfully Reversed.",
                    Buttons = MessageBox.Button.OK,
                    Icon    = MessageBox.Icon.INFO,
                    Width   = 350
                });
                var pvr = new Ext.Net.MVC.PartialViewResult
                {
                    ViewName    = "PortInReversePartial",
                    ContainerId = "MainArea",
                    RenderMode  = RenderMode.AddTo,
                };
                this.GetCmp <TabPanel>("MainArea").SetLastTabAsActive();
                return(pvr);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        //public ActionResult AddReversePurchaseTab(string containerId = "MainArea")
        //{
        //    var pvr = new Ext.Net.MVC.PartialViewResult
        //    {
        //        ViewName = "ReversePurchasePartial",
        //        ContainerId = containerId,
        //        RenderMode = RenderMode.AddTo,
        //    };
        //    this.GetCmp<TabPanel>(containerId).SetLastTabAsActive();
        //    return pvr;
        //}


        public ActionResult SaveRecord_Port(Remit_WithdrawalRepo WithdrawalRepo)
        {
            try
            {
                if ((WithdrawalRepo.Employee_Amount + WithdrawalRepo.Employee_Amount) <= 0)
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Total port-in amount must be more than 0",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });

                    return(this.Direct());
                }

                if (!WithdrawalRepo.Trans_Date.HasValue)
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Sorry!Invalid Date",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });

                    return(this.Direct());
                }

                // validate scheme date
                if (!string.IsNullOrEmpty(WithdrawalRepo.Scheme_Id))
                {
                    GlobalValue.Get_Scheme_Today_Date(WithdrawalRepo.Scheme_Id);
                    if (WithdrawalRepo.Trans_Date != GlobalValue.Scheme_Today_Date)
                    {
                        X.Msg.Show(new MessageBoxConfig
                        {
                            Title   = "Error",
                            Message = "Sorry!Date must be equal to scheme working date ",
                            Buttons = MessageBox.Button.OK,
                            Icon    = MessageBox.Icon.INFO,
                            Width   = 350
                        });

                        return(this.Direct());
                    }
                }
                else
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Employee account cannot be verified.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });
                }


                if (string.IsNullOrEmpty(WithdrawalRepo.Previous_Trustee))
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Previous Trustee is a required field",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });

                    return(this.Direct());
                }

                if (string.IsNullOrEmpty(WithdrawalRepo.GL_Account_No))
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Receiving Account is a required field",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });

                    return(this.Direct());
                }


                WithdrawalRepo.GetESFList(WithdrawalRepo.ESF_Id);


                if (WithdrawalRepo.ESF_Id != null)
                {
                    this.WithdrawalRepo.SaveRecord_Port(WithdrawalRepo);

                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Success",
                        Message = "Port In Successfully Processed.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });
                    var pvr = new Ext.Net.MVC.PartialViewResult
                    {
                        ViewName    = "PortInPartial",
                        ContainerId = "MainArea",
                        RenderMode  = RenderMode.AddTo,
                    };
                    this.GetCmp <TabPanel>("MainArea").SetLastTabAsActive();
                    return(pvr);
                }
                else
                {
                    string messages = string.Join(Environment.NewLine, ModelState.Values
                                                  .SelectMany(x => x.Errors)
                                                  .Select(x => x.ErrorMessage));
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = messages, // " Insufficient data. Operation Aborted",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.ERROR,
                        Width   = 350
                    });
                    return(this.Direct());
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }