public ActionResult ApproveRecord(string RECEIPT_ID, Remit_ReceiptRepo ReceiptRepo)
        {
            try
            {
                if (RECEIPT_ID == string.Empty)
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Sorry! No 'Receipt' has been selected for approval.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.ERROR,
                        Width   = 350
                    });
                    return(this.Direct());
                }
                GlobalValue.Get_Scheme_Today_Date(ReceiptRepo.Scheme_Id);

                if (ReceiptRepo.ApproveReceiptRecord(RECEIPT_ID, ReceiptRepo))
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Success",
                        Message = "Receipt Successfully Approved.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });
                    ClearControls_Approve();
                    Store store = X.GetCmp <Store>("receiptStore");
                    store.Reload();

                    return(this.Direct());
                }
                else
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Operation  failed.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.ERROR,
                        Width   = 350
                    });
                    return(this.Direct());
                }
            }
            catch (Exception ex)
            {
                X.Msg.Show(new MessageBoxConfig
                {
                    Title   = "Error",
                    Message = "Error in approving payment. process aborted. Contact system admin.",
                    Buttons = MessageBox.Button.OK,
                    Icon    = MessageBox.Icon.ERROR,
                    Width   = 350
                });
                return(this.Direct());
            }
        }
 public ActionResult ReadEmployerScheme2(Remit_ReceiptRepo ReceiptRepo)
 {
     try
     {
         return(this.Store(ReceiptRepo.GetEMPLOYERList(ReceiptRepo)));
     }
     catch (Exception ex)
     {
         return(this.Direct());
     }
 }
 public ActionResult Get_Con_Balance(Remit_ReceiptRepo ReceiptRepo)
 {
     try
     {
         X.GetCmp <TextField>("ReceiptPartial_Con_Total").Value = ReceiptRepo.getConBalance(ReceiptRepo);
         return(this.Direct());
     }
     catch (Exception ex)
     {
         return(this.Direct());
     }
 }
 public ActionResult ReadEmployerScheme(Remit_ReceiptRepo rr)
 {
     try
     {
         {
             return(this.Store(ReceiptRepo.GetReceiptESListBTE(rr)));
         }
     }
     catch (Exception ex)
     {
         return(this.Direct());
     }
 }
        // filter employer payments
        public ActionResult FilterERDGrid(Remit_ReceiptRepo ReceiptRepo)
        {
            try
            {
                Store store = X.GetCmp <Store>("purconStore");
                store.Reload();
                store.DataBind();

                return(this.Store(ReceiptRepo.GetERList(ReceiptRepo)));
            }
            catch (Exception ex)
            {
                return(this.Direct());
            }
            finally
            {
            }
        }
        //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 SendRecord(Remit_ReceiptRepo ReceiptRepo)
        {
            try
            {
                if (String.IsNullOrEmpty(ReceiptRepo.Receipt_Id))

                {
                    X.Mask.Hide();
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Please Select Payment",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });

                    return(this.Direct());
                }



                string queryString   = "select * from VW_RECEIPT_EMPLOYER where receipt_id = '" + ReceiptRepo.Receipt_Id + "' ";
                string queryinternet = "select * from setup_company";


                using (OracleConnection connection = new OracleConnection(GlobalValue.ConString))
                {
                    OracleCommand command = new OracleCommand(queryString, connection);
                    connection.Open();
                    OracleDataReader reader;
                    reader = command.ExecuteReader();
                    // Always call Read before accessing data.


                    while (reader.Read())
                    {
                        ReceiptRepo.Scheme_Name         = (string)reader["Scheme_Name"];
                        ReceiptRepo.Employer_Name       = (string)reader["Employer_Name"];
                        ReceiptRepo.Contact_Email       = (string)reader["Contact_Email"];
                        ReceiptRepo.Actual_Receipt_Date = (DateTime)reader["Actual_Receipt_Date"];
                        NEW_DATE = ReceiptRepo.Actual_Receipt_Date.ToString().Replace("/", ".");
                        NEW_DATE = NEW_DATE.Replace(":", ".");


                        if (String.IsNullOrEmpty(ReceiptRepo.Contact_Email))

                        {
                            X.Mask.Hide();
                            X.Msg.Show(new MessageBoxConfig
                            {
                                Title   = "Error",
                                Message = "Sorry! No Email Address. Process aborted",
                                Buttons = MessageBox.Button.OK,
                                Icon    = MessageBox.Icon.INFO,
                                Width   = 350
                            });

                            return(this.Direct());
                        }

                        if (Regex.IsMatch(((string)reader["Contact_Email"]), MatchEmailPattern) == false)
                        {
                            //log this
                        }

                        else
                        {
                            ReceiptRepo.Contact_Email = (string)reader["Contact_Email"];
                            string DocumentName = "NA";
                            string pa           = Server.MapPath("~/Penfad_Reports/employer_Payment_Confirmation.dll");

                            System.Reflection.Assembly assembly_1 = System.Reflection.Assembly.LoadFrom(pa);
                            StiReport My_Report = StiReport.GetReportFromAssembly(assembly_1);

                            //////asign constring
                            My_Report.Dictionary.DataStore.Clear();

                            My_Report.Dictionary.Databases.Add(new StiOracleDatabase("con", GlobalValue.ConString));

                            My_Report[":P_RECEIPT_ID"] = ReceiptRepo.Receipt_Id;

                            string path = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);

                            if (!(System.IO.Directory.Exists(path + @"\" + "PAYMENT_CONFIRMATION" + @"\" + ReceiptRepo.Scheme_Name + @"\" + ReceiptRepo.Employer_Name)))
                            {
                                System.IO.Directory.CreateDirectory(path + @"\" + "PAYMENT_CONFIRMATION" + @"\" + ReceiptRepo.Scheme_Name + @"\" + ReceiptRepo.Employer_Name);
                            }

                            if (!(System.IO.File.Exists(path + @"\" + "PAYMENT_CONFIRMATION" + @"\" + ReceiptRepo.Scheme_Name + @"\" + ReceiptRepo.Employer_Name + @"\" + NEW_DATE + ".pdf")))
                            {
                                System.IO.File.Delete(path + @"\" + "PAYMENT_CONFIRMATION" + @"\" + ReceiptRepo.Scheme_Name + @"\" + ReceiptRepo.Employer_Name + @"\" + NEW_DATE + ".pdf");
                            }
                            DocumentName = (path + @"\" + "PAYMENT_CONFIRMATION" + @"\" + ReceiptRepo.Scheme_Name + @"\" + ReceiptRepo.Employer_Name + @"\" + NEW_DATE + ".pdf");

                            My_Report.Render();
                            My_Report.ExportDocument(StiExportFormat.Pdf, DocumentName);

                            #region send email

                            OracleCommand commandinternet = new OracleCommand(queryinternet, connection);
                            //connection.Open();
                            OracleDataReader readerinternet;
                            readerinternet = commandinternet.ExecuteReader();
                            // Always call Read before accessing data.
                            while (readerinternet.Read())
                            {
                                internetRepo.smtp           = (string)readerinternet["smtp"];
                                internetRepo.email_from     = (string)readerinternet["email_from"];
                                internetRepo.email_password = (string)readerinternet["email_password"];
                                internetRepo.port           = Convert.ToInt16(readerinternet["port"]);
                                internetRepo.company_name   = (string)readerinternet["company_name"];
                            }

                            var    msg = $@"Dear {ReceiptRepo.Contact_Person},   Kindly find attached, Payment Confirmation for  {ReceiptRepo.Scheme_Name}.    Thank you.  {internetRepo.company_name}";
                            string from = internetRepo.email_from, pass = internetRepo.email_password, subj = "Payment Confirmation", to = ReceiptRepo.Contact_Email;
                            string smtp   = internetRepo.smtp;
                            int    port   = internetRepo.port;
                            string attach = DocumentName;
                            internetRepo.SendIt4(from, pass, subj, msg, to, smtp, port, ReceiptRepo, attach);

                            #endregion
                        }
                    }
                    // Always call Close when done reading.
                    reader.Close();
                    X.Mask.Hide();
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Sent",
                        Message = "Emails Successfully Sent",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });
                }
                return(this.Direct());
            }

            catch (Exception ex)
            {
                X.Mask.Hide();
                X.Msg.Show(new MessageBoxConfig
                {
                    Title   = "Error",
                    Message = "Email traffic issue. Process aborted",
                    Buttons = MessageBox.Button.OK,
                    Icon    = MessageBox.Icon.ERROR,
                    Width   = 350
                });
                return(this.Direct());
            }
        }
        public ActionResult DownloadRecord(Remit_ReceiptRepo ReceiptRepo)
        {
            try
            {
                if (String.IsNullOrEmpty(ReceiptRepo.Receipt_Id))

                {
                    X.Mask.Hide();
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Please Select Payment",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });

                    return(this.Direct());
                }
                string queryString = "select * from VW_RECEIPT_EMPLOYER where receipt_id = '" + ReceiptRepo.Receipt_Id + "' ";

                using (OracleConnection connection = new OracleConnection(GlobalValue.ConString))
                {
                    OracleCommand command = new OracleCommand(queryString, connection);
                    connection.Open();
                    OracleDataReader reader;
                    reader = command.ExecuteReader();
                    // Always call Read before accessing data.


                    while (reader.Read())
                    {
                        ReceiptRepo.Scheme_Name         = (string)reader["Scheme_Name"];
                        ReceiptRepo.Employer_Name       = (string)reader["Employer_Name"];
                        ReceiptRepo.Actual_Receipt_Date = (DateTime)reader["Actual_Receipt_Date"];
                        NEW_DATE = ReceiptRepo.Actual_Receipt_Date.ToString().Replace("/", ".");
                        NEW_DATE = NEW_DATE.Replace(":", ".");

                        string DocumentName = "NA";
                        string pa           = Server.MapPath("~/Penfad_Reports/employer_Payment_Confirmation.dll");

                        System.Reflection.Assembly assembly_1 = System.Reflection.Assembly.LoadFrom(pa);
                        StiReport My_Report = StiReport.GetReportFromAssembly(assembly_1);

                        //////asign constring
                        My_Report.Dictionary.DataStore.Clear();
                        My_Report.Dictionary.Databases.Add(new StiOracleDatabase("con", GlobalValue.ConString));

                        My_Report[":P_RECEIPT_ID"] = ReceiptRepo.Receipt_Id;

                        string path = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);

                        if (!(System.IO.Directory.Exists(path + @"\" + "PAYMENT_CONFIRMATION" + @"\" + ReceiptRepo.Scheme_Name + @"\" + ReceiptRepo.Employer_Name)))
                        {
                            System.IO.Directory.CreateDirectory(path + @"\" + "PAYMENT_CONFIRMATION" + @"\" + ReceiptRepo.Scheme_Name + @"\" + ReceiptRepo.Employer_Name);
                        }

                        if (!(System.IO.File.Exists(path + @"\" + "PAYMENT_CONFIRMATION" + @"\" + ReceiptRepo.Scheme_Name + @"\" + ReceiptRepo.Employer_Name + @"\" + NEW_DATE + ".pdf")))
                        {
                            System.IO.File.Delete(path + @"\" + "PAYMENT_CONFIRMATION" + @"\" + ReceiptRepo.Scheme_Name + @"\" + ReceiptRepo.Employer_Name + @"\" + NEW_DATE + ".pdf");
                        }
                        DocumentName = (path + @"\" + "PAYMENT_CONFIRMATION" + @"\" + ReceiptRepo.Scheme_Name + @"\" + ReceiptRepo.Employer_Name + @"\" + NEW_DATE + ".pdf");

                        My_Report.Render();
                        My_Report.ExportDocument(StiExportFormat.Pdf, DocumentName);
                        ////return StiMvcViewer.GetReportSnapshotResult(My_Report);
                    }
                    // Always call Close when done reading.
                    reader.Close();
                    X.Mask.Hide();
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Successful",
                        Message = "Payment Confirmation Successfully Downloaded",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });
                }
                return(this.Direct());
            }

            catch (Exception EX)
            {
                X.Mask.Hide();
                X.Msg.Show(new MessageBoxConfig
                {
                    Title   = "Error",
                    Message = "Could not download Payment Advice",
                    Buttons = MessageBox.Button.OK,
                    Icon    = MessageBox.Icon.ERROR,
                    Width   = 350
                });
                return(this.Direct());
            }
        }
        public ActionResult ReverseRecord(Remit_ReceiptRepo ReceiptRepo)
        {
            try
            {
                if (ReceiptRepo.Receipt_Id == string.Empty)
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Sorry! No 'Receipt' has been selected for Reversal.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.ERROR,
                        Width   = 350
                    });
                    return(this.Direct());
                }

                GlobalValue.Get_Scheme_Today_Date(ReceiptRepo.Scheme_Id);

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

                //        });

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

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

                //}


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

                //if (!string.IsNullOrEmpty(ReceiptRepo.ES_Id))
                //{
                //    ReceiptRepo.Scheme_Id = ReceiptRepo.ES_Id.Substring(ReceiptRepo.ES_Id.Length - 2);
                //}
                //if (!string.IsNullOrEmpty(ReceiptRepo.Scheme_Id))
                //{
                //    GlobalValue.Get_Scheme_Today_Date(ReceiptRepo.Scheme_Id);
                //}

                if (ReceiptRepo.ReverseReceiptRecord(ReceiptRepo))
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Success",
                        Message = "Receipt Successfully Reversed.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });
                    ClearControls_Reverse();
                    Store store = X.GetCmp <Store>("RreceiptStore");
                    store.Reload();

                    return(this.Direct());
                }
                else
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Operation  failed.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.ERROR,
                        Width   = 350
                    });
                    return(this.Direct());
                }
            }
            catch (Exception ex)
            {
                return(this.Direct());
            }
        }
        public ActionResult SaveRecord(Remit_ReceiptRepo ReceiptRepo)
        {
            try
            {
                if (!string.IsNullOrEmpty(ReceiptRepo.Scheme_Id))
                {
                    GlobalValue.Get_Scheme_Today_Date(ReceiptRepo.Scheme_Id);
                    if (ReceiptRepo.Actual_Receipt_Date != GlobalValue.Scheme_Today_Date)
                    {
                        X.Msg.Show(new MessageBoxConfig
                        {
                            Title   = "Error",
                            Message = "Sorry! Actual payment date must be equal to scheme working date of " + GlobalValue.Scheme_Today_Date.Date.ToString(),
                            Buttons = MessageBox.Button.OK,
                            Icon    = MessageBox.Icon.INFO,
                            Width   = 350
                        });

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



                if (ReceiptRepo.Trans_Amount <= 0)
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Sorry! Amount must be more than '0'.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });

                    return(this.Direct());
                }


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

                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Success",
                        Message = "Receipt Successfully Processed.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });
                    ClearControls();
                    Store store = X.GetCmp <Store>("receiptStore");
                    store.Reload();
                    return(this.Direct());
                }
                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)
            {
                X.Msg.Show(new MessageBoxConfig
                {
                    Title   = "Error",
                    Message = "Operation  failed.",
                    Buttons = MessageBox.Button.OK,
                    Icon    = MessageBox.Icon.ERROR,
                    Width   = 350
                });
                return(this.Direct());
            }
        }
예제 #11
0
        public void SendIt4(string from, string pass, string subj, string msg, string to, string smtp, int port, Remit_ReceiptRepo ReceiptRepo, string attach)
        {
            try
            {
                MailMessage mail = new MailMessage();
                System.Net.Mail.SmtpClient  SmtpServer  = new System.Net.Mail.SmtpClient();
                System.Net.Mail.MailAddress fromaddress = new System.Net.Mail.MailAddress(from, company_name);

                System.Net.Mail.Attachment attachment;
                attachment = new System.Net.Mail.Attachment(attach);
                mail.Attachments.Add(attachment);

                mail.From = fromaddress;
                mail.To.Add(to);
                mail.Subject              = subj;
                mail.Body                 = msg;
                mail.IsBodyHtml           = true;
                SmtpServer.Port           = port;
                SmtpServer.Host           = smtp;
                SmtpServer.EnableSsl      = true;
                SmtpServer.DeliveryMethod = SmtpDeliveryMethod.Network;
                SmtpServer.Credentials    = new System.Net.NetworkCredential(from, pass);
                SmtpServer.Send(mail);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }