示例#1
0
 //status employee
 public void EmployeeStatus(crm_EmployeeRepo empRepo)
 {
     try
     {
         //Get Connection
         AppSettings app = new AppSettings();
         con = app.GetConnection();
         DynamicParameters param = new DynamicParameters();
         param.Add(name: "p_Cust_No", value: empRepo.Cust_No, dbType: DbType.String, direction: ParameterDirection.Input);
         param.Add(name: "p_Cust_Status", value: empRepo.Cust_Status, dbType: DbType.String, direction: ParameterDirection.Input);
         param.Add(name: "p_Cust_Status_New", value: empRepo.Cust_Status_New, dbType: DbType.String, direction: ParameterDirection.Input);
         param.Add(name: "p_Maker_Id", value: GlobalValue.User_ID, dbType: DbType.String, direction: ParameterDirection.Input);
         param.Add(name: "p_Make_date", value: GlobalValue.Scheme_Today_Date, dbType: DbType.DateTime, direction: ParameterDirection.Input);
         con.Execute("CHG_CRM_EMPLOYEE_STATUS", param, commandType: CommandType.StoredProcedure);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         if (con.State == ConnectionState.Open)
         {
             con.Close();
             if (con != null)
             {
                 con = null;
             }
         }
     }
 }
 public ActionResult Get_EmployeesInBatchLogPending(crm_EmployeeRepo emp)
 {
     //var log = new LoggerConfiguration().WriteTo.Seq("http://localhost:5341").CreateLogger();
     try
     {
         return(this.Store(employee_repo.GetEmployee_BatchList_ByStatus(emp.Batch_No)));
     }
     catch (Exception ex)
     {
         // log.Write(level: Serilog.Events.LogEventLevel.Information, messageTemplate: ex.Message + " " + DateTime.Now);
         return(this.Direct());
     }
 }
        // filter employer scheme for employeeFilterEmpolyeeSFGrid
        public ActionResult FilterESGrid(string Employer_Id)
        {
            var misdepartmentrepo = new crm_EmployeeRepo();
            var mydata            = misdepartmentrepo.GetEmployerSFList(Employer_Id);

            List <object> data = new List <object>();

            foreach (var ddd in mydata)
            {
                string id   = ddd.Scheme_Fund_Id;
                string name = ddd.Scheme_Name + " / " + ddd.Fund_Name;

                data.Add(new { Id = id, Name = name });
            }

            return(this.Store(data));
        }
        public ActionResult DownloadActive(crm_EmployeeRepo employeeRepo)
        {

            try
            {
                if (String.IsNullOrEmpty(employeeRepo.Employer_Id))

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

                    });

                    return this.Direct();
                }
                string queryString = "select * from vw_es_esf where employer_id = '" + employeeRepo.Employer_Id + "' and scheme_id = '" + employeeRepo.Scheme_Id + "' and ESF_STATUS = 'ACTIVE' and deferred < 3";


                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())
                    {


                        employeeRepo.Surname = (string)reader["surname"];
                        employeeRepo.First_Name = (string)reader["first_name"];
                        employeeRepo.ESF_Id = (string)reader["esf_id"];
                        //employeeRepo.Email_Address = (string)reader["email_address"];
                        employeeRepo.Scheme_Name = (string)reader["SCHEME_NAME"];

                        ////load report table
                        //var con = new AppSettings();
                        //var param = new DynamicParameters();
                        //param.Add("P_ESF_ID", employeeRepo.ESF_Id, DbType.String, ParameterDirection.Input);
                        //param.Add("P_MAKER_ID", GlobalValue.User_ID, DbType.String, ParameterDirection.Input);
                        //con.GetConnection().Execute("REPORT_EMPLOYEE_STATEMENT", param, commandType: CommandType.StoredProcedure);


                        string DocumentName = "NA";
                        string pa = Server.MapPath("~/Penfad_Reports/Employee_ContributionMonth_On_Month_1.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_ESF_ID"] = employeeRepo.ESF_Id;

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

                        if (!(System.IO.Directory.Exists(path + @"\" + "STATEMENTS" + @"\" + employeeRepo.Employer_Name + @"\" + System.DateTime.Now.Day + "_" + System.DateTime.Now.Month + "_" + System.DateTime.Now.Year)))
                        {
                            System.IO.Directory.CreateDirectory(path + @"\" + "STATEMENTS" + @"\" + employeeRepo.Employer_Name + @"\" + System.DateTime.Now.Day + "_" + System.DateTime.Now.Month + "_" + System.DateTime.Now.Year);
                        }

                        if (!(System.IO.File.Exists(path + @"\" + "STATEMENTS" + @"\" + employeeRepo.Employer_Name + @"\" + System.DateTime.Now.Day + "_" + System.DateTime.Now.Month + "_" + System.DateTime.Now.Year + @"\" + employeeRepo.First_Name + "_" + employeeRepo.Surname + "_" + employeeRepo.ESF_Id + "_" + employeeRepo.Scheme_Name + "_Statement.pdf")))
                        {
                            System.IO.File.Delete(path + @"\" + "STATEMENTS" + @"\" + employeeRepo.Employer_Name + @"\" + System.DateTime.Now.Day + "_" + System.DateTime.Now.Month + "_" + System.DateTime.Now.Year + @"\" + employeeRepo.First_Name + "_" + employeeRepo.Surname + "_" + employeeRepo.ESF_Id + "_" + employeeRepo.Scheme_Name + "_Statement.pdf");
                        }
                        DocumentName = (path + @"\" + "STATEMENTS" + @"\" + employeeRepo.Employer_Name + @"\" + System.DateTime.Now.Day + "_" + System.DateTime.Now.Month + "_" + System.DateTime.Now.Year + @"\" + employeeRepo.First_Name + "_" + employeeRepo.Surname + "_" + employeeRepo.ESF_Id + "_" + employeeRepo.Scheme_Name + "_Statement.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 = "Statements 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 statements",
                    Buttons = MessageBox.Button.OK,
                    Icon = MessageBox.Icon.ERROR,
                    Width = 350
                });
                return this.Direct();
            }
        }
        public ActionResult ApproveEditingEmployee(crm_EmployeeRepo crmEmployee)
        {
            try
            {
                //if (ModelState.IsValid)
                //{
                var empId = crmEmployee.Employee_Id;

                crmEmployee.Employee_Photo    = mImage;
                crmEmployee.Employee_Photo_Id = mImageID;

                if (string.IsNullOrEmpty(empId))
                {
                    X.Mask.Hide();
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Select an employee to approve.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });
                    return(this.Direct());
                }

                //Save new employee
                if (this.employeeRepo.UpdateEmployeeWithEmpTmp(crmEmployee))
                {
                    X.Mask.Hide();
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Success",
                        Message = "Employee: " + crmEmployee.Surname + " " + crmEmployee.First_Name + " approved Successfully.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });
                    //clear controls
                    ClearControls();
                }
                else
                {
                    X.Mask.Hide();
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Process aborted.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });
                    return(this.Direct());
                }
                Store store = X.GetCmp <Store>("empEditingApprove_employeeStore");
                store.Reload();

                //}
                //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)
            {
                X.Mask.Hide();
                logger.WriteLog(ex.Message);
                X.Msg.Show(new MessageBoxConfig
                {
                    Title   = "Error",
                    Message = "Process failed -" + ex.Message,
                    Buttons = MessageBox.Button.OK,
                    Icon    = MessageBox.Icon.INFO,
                    Width   = 350
                });
                return(this.Direct());
            }
        }
        public ActionResult SaveRecord(crm_EmployeeRepo crmEmployee)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    crmEmployee.Employee_Photo    = mImage;
                    crmEmployee.Employee_Photo_Id = mImage_ID;

                    //-------------------------------------------------------------------
                    //Validate Employee Identity Number and SSNIT if its a new record
                    //-------------------------------------------------------------------
                    if (string.IsNullOrEmpty(crmEmployee.Employee_Id))
                    {
                        //check if employee Identity Number exist
                        if (employeeRepo.EmployeeIdentityIdNumberExist(crmEmployee.Identity_Type, crmEmployee.Identity_Number))
                        {
                            X.Msg.Show(new MessageBoxConfig
                            {
                                Title   = "Error",
                                Message = "Employee Identity number has already been assigned to another employee.",
                                Buttons = MessageBox.Button.OK,
                                Icon    = MessageBox.Icon.INFO,
                                Width   = 350
                            });
                            return(this.Direct());
                        }

                        if (employeeRepo.SocialSecurityNumberExist(crmEmployee.SSNIT_NO))
                        {
                            X.Msg.Show(new MessageBoxConfig
                            {
                                Title   = "Error",
                                Message = "Employee SSNIT No. has already been assigned to another employee.",
                                Buttons = MessageBox.Button.OK,
                                Icon    = MessageBox.Icon.INFO,
                                Width   = 350
                            });
                            return(this.Direct());
                        }
                    }
                    if (string.IsNullOrEmpty(crmEmployee.Employer_Id))
                    {
                        X.Msg.Show(new MessageBoxConfig
                        {
                            Title   = "Error",
                            Message = "Employer name is required",
                            Buttons = MessageBox.Button.OK,
                            Icon    = MessageBox.Icon.INFO,
                            Width   = 350
                        });
                        return(this.Direct());
                    }
                    if (string.IsNullOrEmpty(crmEmployee.Scheme_Fund_Id))
                    {
                        X.Msg.Show(new MessageBoxConfig
                        {
                            Title   = "Error",
                            Message = "Scheme Account is required",
                            Buttons = MessageBox.Button.OK,
                            Icon    = MessageBox.Icon.INFO,
                            Width   = 350
                        });
                        return(this.Direct());
                    }
                    if (!string.IsNullOrEmpty(crmEmployee.Mobile_Number))
                    {
                        if (Microsoft.VisualBasic.Information.IsNumeric(crmEmployee.Mobile_Number) == false)
                        {
                            X.Msg.Show(new MessageBoxConfig
                            {
                                Title   = "Error",
                                Message = "Primary phone number must be numbers.",
                                Buttons = MessageBox.Button.OK,
                                Icon    = MessageBox.Icon.INFO,
                                Width   = 350
                            });
                            return(this.Direct());
                        }
                    }
                    if (!string.IsNullOrEmpty(crmEmployee.Father_Phone_Number))
                    {
                        if (Microsoft.VisualBasic.Information.IsNumeric(crmEmployee.Father_Phone_Number) == false)
                        {
                            X.Msg.Show(new MessageBoxConfig
                            {
                                Title   = "Error",
                                Message = "Father's phone number must be numbers.",
                                Buttons = MessageBox.Button.OK,
                                Icon    = MessageBox.Icon.INFO,
                                Width   = 350
                            });
                            return(this.Direct());
                        }
                    }
                    if (!string.IsNullOrEmpty(crmEmployee.Mother_Phone_Number))
                    {
                        if (Microsoft.VisualBasic.Information.IsNumeric(crmEmployee.Mother_Phone_Number) == false)
                        {
                            X.Msg.Show(new MessageBoxConfig
                            {
                                Title   = "Error",
                                Message = "Mother's phone number must be numbers.",
                                Buttons = MessageBox.Button.OK,
                                Icon    = MessageBox.Icon.INFO,
                                Width   = 350
                            });
                            return(this.Direct());
                        }
                    }
                    if (!string.IsNullOrEmpty(crmEmployee.Other_Number))
                    {
                        if (Microsoft.VisualBasic.Information.IsNumeric(crmEmployee.Other_Number) == false)
                        {
                            X.Msg.Show(new MessageBoxConfig
                            {
                                Title   = "Error",
                                Message = "Secondary phone number must be numbers.",
                                Buttons = MessageBox.Button.OK,
                                Icon    = MessageBox.Icon.INFO,
                                Width   = 350
                            });
                            return(this.Direct());
                        }
                    }
                    if (!string.IsNullOrEmpty(crmEmployee.Email_Address))
                    {
                        if (Regex.IsMatch(crmEmployee.Email_Address, MatchEmailPattern) == false)
                        {
                            X.Msg.Show(new MessageBoxConfig
                            {
                                Title   = "Error",
                                Message = "Primary email address is not valid.",
                                Buttons = MessageBox.Button.OK,
                                Icon    = MessageBox.Icon.INFO,
                                Width   = 350
                            });
                            return(this.Direct());
                        }
                    }
                    if (!string.IsNullOrEmpty(crmEmployee.Other_Email_Address))
                    {
                        if (Regex.IsMatch(crmEmployee.Other_Email_Address, MatchEmailPattern) == false)
                        {
                            X.Msg.Show(new MessageBoxConfig
                            {
                                Title   = "Error",
                                Message = "Secondary email address is not valid.",
                                Buttons = MessageBox.Button.OK,
                                Icon    = MessageBox.Icon.INFO,
                                Width   = 350
                            });
                            return(this.Direct());
                        }
                    }
                    if (DateTime.Compare(crmEmployee.Date_Of_Birth, DateTime.Today) >= 0)
                    {
                        X.Msg.Show(new MessageBoxConfig
                        {
                            Title   = "Error",
                            Message = "DOB can not be today or in the future.",
                            Buttons = MessageBox.Button.OK,
                            Icon    = MessageBox.Icon.INFO,
                            Width   = 350
                        });
                        return(this.Direct());
                    }

                    if (string.IsNullOrEmpty(crmEmployee.Mobile_Number))
                    {
                        crmEmployee.Mobile_Number = "0";
                    }



                    ///check if Employee_ID exist

                    //Save new employee
                    if (this.employeeRepo.AddNewEmployeeRecord(crmEmployee))
                    {
                        X.Msg.Show(new MessageBoxConfig
                        {
                            Title   = "Success",
                            Message = "Saved Successfully.",
                            Buttons = MessageBox.Button.OK,
                            Icon    = MessageBox.Icon.INFO,
                            Width   = 350
                        });
                        //clear controls
                        ClearControls();
                        this.GetCmp <Image>("AddEmp_new_pic1").ImageUrl = "";
                        this.GetCmp <Image>("AddEmp_new_pic2").ImageUrl = "";
                    }
                    else
                    {
                        X.Msg.Show(new MessageBoxConfig
                        {
                            Title   = "Error",
                            Message = "Process aborted.",
                            Buttons = MessageBox.Button.OK,
                            Icon    = MessageBox.Icon.INFO,
                            Width   = 350
                        });
                        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 ex)
            {
                //logger.WriteLog(ex.Message);

                X.Msg.Show(new MessageBoxConfig
                {
                    Title   = "Error",
                    Message = "Process failed -" + ex.Message,
                    Buttons = MessageBox.Button.OK,
                    Icon    = MessageBox.Icon.INFO,
                    Width   = 350
                });
                return(this.Direct());
            }
        }
示例#7
0
        public ActionResult SendIndiMail(crm_EmployeeRepo employeeRepo)
        {
            try
            {
                if (String.IsNullOrEmpty(employeeRepo.Employer_Id))
                {
                    X.Mask.Hide();
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Please Select Employer",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });
                    return(this.Direct());
                }
                string queryString   = "select * from vw_es_esf where esf_id = '" + employeeRepo.ESF_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();

                    var con    = new AppSettings();
                    var paramc = new DynamicParameters();
                    con.GetConnection().Execute("CHECK_EMAIL_NA", paramc, commandType: CommandType.StoredProcedure);



                    // Always call Read before accessing data.
                    while (reader.Read())
                    {
                        employeeRepo.Surname       = (string)reader["surname"];
                        employeeRepo.First_Name    = (string)reader["first_name"];
                        employeeRepo.ESF_Id        = (string)reader["esf_id"];
                        employeeRepo.Email_Address = (string)reader["email_address"];
                        employeeRepo.Scheme_Name   = (string)reader["SCHEME_NAME"];

                        if (Regex.IsMatch(((string)reader["email_address"]), MatchEmailPattern) == false)
                        {
                            //log this
                        }
                        else
                        {
                            //load report table
                            //var con = new AppSettings();
                            var param = new DynamicParameters();
                            param.Add("P_ESF_ID", employeeRepo.ESF_Id, DbType.String, ParameterDirection.Input);
                            param.Add("P_MAKER_ID", GlobalValue.User_ID, DbType.String, ParameterDirection.Input);
                            con.GetConnection().Execute("REPORT_EMPLOYEE_STATEMENT", param, commandType: CommandType.StoredProcedure);

                            employeeRepo.Email_Address = (string)reader["email_address"];

                            string DocumentName = "NA";
                            string pa           = Server.MapPath("~/Penfad_Reports/Employee_ContributionMonth_On_Month_1.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_ESF_ID"]  = employeeRepo.ESF_Id;
                            My_Report[":P_USER_ID"] = GlobalValue.User_ID;
                            NEW_DATE = System.DateTime.Now.ToString().Replace("/", ".");
                            NEW_DATE = NEW_DATE.Replace(":", ".");

                            if (!(System.IO.Directory.Exists(path + @"\" + "STATEMENTS_MAIL" + @"\" + employeeRepo.First_Name + "_" + employeeRepo.Surname + @"\" + System.DateTime.Now.Day + "_" + System.DateTime.Now.Month + "_" + System.DateTime.Now.Year)))
                            {
                                System.IO.Directory.CreateDirectory(path + @"\" + "STATEMENTS_MAIL" + @"\" + employeeRepo.First_Name + "_" + employeeRepo.Surname + @"\" + System.DateTime.Now.Day + "_" + System.DateTime.Now.Month + "_" + System.DateTime.Now.Year);
                            }

                            if ((System.IO.File.Exists(path + @"\" + "STATEMENTS_MAIL" + @"\" + employeeRepo.First_Name + "_" + employeeRepo.Surname + @"\" + System.DateTime.Now.Day + "_" + System.DateTime.Now.Month + "_" + System.DateTime.Now.Year + @"\" + employeeRepo.Scheme_Name + "_" + NEW_DATE + "_Statement.pdf")))
                            {
                                System.IO.File.Delete(path + @"\" + "STATEMENTS_MAIL" + @"\" + employeeRepo.First_Name + "_" + employeeRepo.Surname + @"\" + System.DateTime.Now.Day + "_" + System.DateTime.Now.Month + "_" + System.DateTime.Now.Year + @"\" + employeeRepo.Scheme_Name + "_" + NEW_DATE + "_Statement.pdf");
                            }

                            DocumentName = (path + @"\" + "STATEMENTS_MAIL" + @"\" + employeeRepo.First_Name + "_" + employeeRepo.Surname + @"\" + System.DateTime.Now.Day + "_" + System.DateTime.Now.Month + "_" + System.DateTime.Now.Year + @"\" + employeeRepo.Scheme_Name + "_" + NEW_DATE + "_Statement.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 {employeeRepo.First_Name}," + "<br/>" + $@" Kindly find attached, your {employeeRepo.Scheme_Name} statement." + "<br/>" + $@"Thank you." + "<br/>" + $@" { internetRepo.company_name}";
                            string from = internetRepo.email_from, pass = internetRepo.email_password, subj = "Statement of Account", to = employeeRepo.Email_Address;
                            string smtp   = internetRepo.smtp;
                            int    port   = internetRepo.port;
                            string attach = DocumentName;
                            internetRepo.SendIt2(from, pass, subj, msg, to, smtp, port, employeeRepo, attach);

                            #endregion

                            //update crm_employee_scheme_fund for email sent
                            var parame = new DynamicParameters();
                            parame.Add("P_ESF_ID", employeeRepo.ESF_Id, DbType.String, ParameterDirection.Input);
                            //parame.Add("P_DATE_ID", System.DateTime.Now.ToString("dd-MMM-yyyy"), DbType.DateTime, ParameterDirection.Input);
                            con.GetConnection().Execute("REPORT_UP_CRM_ACCOUNT", parame, commandType: CommandType.StoredProcedure);
                        }
                    }

                    // Always call Close when done reading.
                    reader.Close();
                    X.Mask.Hide();
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Sent",
                        Message = "Email 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 = "Could not send email, check internet connection",
                    Buttons = MessageBox.Button.OK,
                    Icon    = MessageBox.Icon.ERROR,
                    Width   = 350
                });
                return(this.Direct());
            }
        }
示例#8
0
        public bool BatchEmployeeUpload(string filePath, string Employer_number, string scheme_id)
        {
            try
            {
                if (System.IO.File.Exists(filePath) == false)
                {
                    X.Mask.Hide();
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "File does not exist.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.ERROR,
                        Width   = 350
                    });
                    return(false);
                }
                //'get file extension
                string file_ext = Path.GetExtension(filePath);

                string consString_excel = "";

                switch (file_ext)
                {
                case ".xls":
                    consString_excel = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Extended Properties=Excel 8.0;HDR=Yes;IMEX=2";

                    break;

                case ".xlsx":
                    consString_excel = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filePath + ";Extended Properties=\"Excel 12.0 Xml;HDR=YES\"";

                    break;
                }

                OleDbConnection con_ex = new OleDbConnection();
                OleDbCommand    cmd    = new OleDbCommand();

                string query1   = "Select COUNT(*) AS NOS From [EmployeeScheme$]";
                string query2   = "Select * From [EmployeeScheme$]";
                int    totalsum = 1;

                con_ex.ConnectionString = consString_excel;
                con_ex.Open();

                cmd.Connection  = con_ex;
                cmd.CommandText = query1;

                totalsum = Convert.ToInt32(cmd.ExecuteScalar()); //();
                con_ex.Close();

                if (con_ex.State == ConnectionState.Closed)
                {
                    con_ex.Open();
                }



                if (con_ex.State == ConnectionState.Open)
                {
                    cmd.Connection  = con_ex;
                    cmd.CommandText = query2;
                    OleDbDataReader srda = cmd.ExecuteReader();

                    int a_value = 0;

                    if (srda.HasRows)
                    {
                        string errormsg = "";

                        Stopwatch sw = new Stopwatch();
                        // Start The StopWatch ...From 000
                        sw.Start();
                        var app = new AppSettings();
                        //IDbConnection con;

                        DateTime date_default = Convert.ToDateTime("01/01/1901");

                        TransactionOptions tsOp = new TransactionOptions();
                        tsOp.IsolationLevel = System.Transactions.IsolationLevel.Snapshot;
                        TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew, tsOp);
                        tsOp.Timeout = TimeSpan.FromMinutes(20);

                        using (OracleConnection conn = new OracleConnection(app.conString()))  //
                        {
                            conn.Open();

                            try
                            {
                                //check if pending list exist for employer already
                                var     param_k = new DynamicParameters();
                                decimal emp_num = 0;
                                param_k.Add(name: "p_employer_id", value: Employer_number, dbType: DbType.String, direction: ParameterDirection.Input);
                                param_k.Add(name: "p_status", value: "ACTIVE", dbType: DbType.String, direction: ParameterDirection.Input);
                                param_k.Add(name: "p_result", value: emp_num, dbType: DbType.Decimal, direction: ParameterDirection.Output);
                                conn.Execute(sql: "sel_crm_employerbatchpendexist", param: param_k, commandType: CommandType.StoredProcedure);
                                decimal tot_emp = param_k.Get <decimal>("p_result");
                                if (tot_emp > 0)
                                {
                                    X.Mask.Hide();
                                    X.Msg.Show(new MessageBoxConfig
                                    {
                                        Title   = "Error",
                                        Message = "Pending upload exists for this employer already." + Environment.NewLine + "Approve the pending employees.Proces aborted",
                                        Buttons = MessageBox.Button.OK,
                                        Icon    = MessageBox.Icon.ERROR,
                                        Width   = 350
                                    });
                                    return(false);
                                }

                                ///create log for the upload P_scheme_id
                                var    paramb  = new DynamicParameters();
                                string batchno = "na";
                                paramb.Add(name: "p_Maker_Id", value: GlobalValue.User_ID, dbType: DbType.String, direction: ParameterDirection.Input);
                                paramb.Add(name: "p_Make_Date", value: GlobalValue.Scheme_Today_Date, dbType: DbType.DateTime, direction: ParameterDirection.Input);
                                paramb.Add(name: "p_employer_id", value: Employer_number, dbType: DbType.String, direction: ParameterDirection.Input);
                                paramb.Add(name: "p_BatchNo", value: batchno, dbType: DbType.String, direction: ParameterDirection.Output);
                                paramb.Add(name: "p_scheme_id", value: scheme_id, dbType: DbType.String, direction: ParameterDirection.Input);
                                conn.Execute(sql: "ADD_CRM_EMPLOYEE_BATCH_TWO", param: paramb, commandType: CommandType.StoredProcedure);
                                batchno = paramb.Get <string>("p_BatchNo");
                                if (batchno == "na")
                                {
                                    X.Mask.Hide();
                                    X.Msg.Show(new MessageBoxConfig
                                    {
                                        Title   = "Error",
                                        Message = "Employer details could not be logged.",
                                        Buttons = MessageBox.Button.OK,
                                        Icon    = MessageBox.Icon.ERROR,
                                        Width   = 350
                                    });
                                    return(false);
                                }
                                //-----end batch number
                                int    error_nos  = 0;
                                string erroor_msg = "Error:" + Environment.NewLine;
                                var    param      = new DynamicParameters();

                                //this.GetCmp<Label>("lblload").Text = "Loading";

                                while (srda.Read())
                                {
                                    a_value += 1;

                                    crm_EmployeeRepo employee_Repo = new crm_EmployeeRepo();

                                    string employee_fund_id = "";

                                    //surname
                                    if (srda["Surname"] != DBNull.Value)
                                    {
                                        employee_Repo.Surname = srda["Surname"].ToString();
                                    }
                                    else
                                    {
                                        X.Mask.Hide();
                                        error_nos += 1;
                                        erroor_msg = erroor_msg + "Surname cannot be null." + Environment.NewLine;
                                    }
                                    //FirstName
                                    if (srda["FirstName"] != DBNull.Value)
                                    {
                                        employee_Repo.First_Name = srda["FirstName"].ToString();
                                    }
                                    else
                                    {
                                        X.Mask.Hide();
                                        error_nos += 1;
                                        erroor_msg = erroor_msg + "Supply First Name For " + employee_Repo.Surname + Environment.NewLine;
                                    }
                                    //verify Company's EmployeID
                                    //get CustNo for employee
                                    int    create_new_or_justacct = 1; // 1 for create new employee , 2 for creat just account
                                    string cust_noo = "";
                                    if (srda["CompanyEmployeeID"] != DBNull.Value)
                                    {
                                        employee_Repo.Employee_Id = srda["CompanyEmployeeID"].ToString();
                                        //Validate EmployeeID against Employer to check if its already exist
                                        OracleCommand cmd_emp_id = new OracleCommand();
                                        cmd_emp_id.CommandText = "sel_crm_EmployeeIdExist";
                                        cmd_emp_id.CommandType = CommandType.StoredProcedure;
                                        cmd_emp_id.Connection  = (OracleConnection)conn;
                                        //Input param
                                        cmd_emp_id.Parameters.Add("p_EmployerId", OracleDbType.Varchar2, ParameterDirection.Input).Value = Employer_number;
                                        cmd_emp_id.Parameters.Add("p_EmployeeId", OracleDbType.Varchar2, ParameterDirection.Input).Value = employee_Repo.Employee_Id;
                                        //Output param
                                        OracleParameter count    = new OracleParameter("p_result", OracleDbType.Decimal, 100, ParameterDirection.Output);
                                        OracleParameter cust_num = new OracleParameter("p_custNo", OracleDbType.Varchar2, 4000, null, ParameterDirection.Output);
                                        cmd_emp_id.Parameters.Add(count);
                                        cmd_emp_id.Parameters.Add(cust_num);

                                        cmd_emp_id.ExecuteNonQuery();
                                        cust_noo = (cust_num.Value).ToString();
                                        string mtotal = (count.Value).ToString();
                                        int    total  = Convert.ToInt32(mtotal);
                                        if (total > 0)
                                        {
                                            create_new_or_justacct = 2;
                                            employee_Repo.Cust_No  = cust_noo;
                                            //error_nos += 1;
                                            //erroor_msg = erroor_msg + "Employee ID already exist For this employer. - " + employee_Repo.Surname + Environment.NewLine;
                                            //get custNo
                                        }
                                    }
                                    else
                                    {
                                        X.Mask.Hide();
                                        error_nos += 1;
                                        erroor_msg = erroor_msg + "Supply Employee ID For " + employee_Repo.First_Name + " " + employee_Repo.Surname + Environment.NewLine;
                                    }


                                    if (create_new_or_justacct == 1)
                                    {
                                        //Fundid
                                        if (srda["FundID"] != DBNull.Value)
                                        {
                                            employee_fund_id = srda["FundID"].ToString();
                                        }
                                        else
                                        {
                                            X.Mask.Hide();
                                            error_nos += 1;
                                            erroor_msg = erroor_msg + "Scheme ID not provided for ." + employee_Repo.First_Name + " " + employee_Repo.Surname + Environment.NewLine;
                                        }

                                        if (employee_fund_id == "01")
                                        {
                                            X.Mask.Hide();
                                            error_nos += 1;
                                            erroor_msg = erroor_msg + "Employee cannot subscribe to system fund (01)- " + employee_Repo.First_Name + " " + employee_Repo.Surname + Environment.NewLine;
                                        }
                                        //Sceme_Fund_ID
                                        string Scheme_fund_id = scheme_id + employee_fund_id;
                                        if (string.IsNullOrEmpty(Scheme_fund_id) == false)
                                        {
                                            //Validate Employee SchemeFundID  to check if its already exist
                                            OracleCommand cmd_emp_id = new OracleCommand();
                                            cmd_emp_id.CommandText = "sel_pfm_SchemeFundIdExist";
                                            cmd_emp_id.CommandType = CommandType.StoredProcedure;
                                            cmd_emp_id.Connection  = (OracleConnection)conn;
                                            //Input param
                                            cmd_emp_id.Parameters.Add("p_scheme_fund_id", OracleDbType.Varchar2, ParameterDirection.Input).Value = Scheme_fund_id;
                                            //Output param
                                            OracleParameter count = new OracleParameter("p_result", OracleDbType.Decimal, 100, ParameterDirection.Output);
                                            cmd_emp_id.Parameters.Add(count);
                                            cmd_emp_id.ExecuteNonQuery();
                                            string mtotal = (count.Value).ToString();
                                            int    total  = Convert.ToInt32(mtotal);
                                            if (total <= 0)
                                            {
                                                X.Mask.Hide();
                                                error_nos += 1;
                                                erroor_msg = erroor_msg + "Scheme fund does not exist for . - " + employee_Repo.First_Name + " " + employee_Repo.Surname + Environment.NewLine;
                                            }
                                        }
                                        else
                                        {
                                            X.Mask.Hide();
                                            error_nos += 1;
                                            erroor_msg = erroor_msg + "Scheme fund does not exist for . - " + employee_Repo.First_Name + " " + employee_Repo.Surname + Environment.NewLine;
                                        }
                                    }



                                    else if (create_new_or_justacct == 2)  /////Just create schme fund account for employee
                                    {
                                        //Fundid
                                        if (srda["FundID"] != DBNull.Value)
                                        {
                                            employee_fund_id = srda["FundID"].ToString();
                                        }
                                        else
                                        {
                                            X.Mask.Hide();
                                            error_nos += 1;
                                            erroor_msg = erroor_msg + "Fund ID not provided for ." + employee_Repo.First_Name + " " + employee_Repo.Surname + Environment.NewLine;
                                        }


                                        //Sceme_Fund_ID
                                        string Scheme_fund_id = scheme_id + employee_fund_id;
                                        if (string.IsNullOrEmpty(Scheme_fund_id) == false)
                                        {
                                            //Validate Employee SchemeFundID  to check if its already exist
                                            OracleCommand cmd_emp_id = new OracleCommand();
                                            cmd_emp_id.CommandText = "sel_pfm_SchemeFundIdExist";
                                            cmd_emp_id.CommandType = CommandType.StoredProcedure;
                                            cmd_emp_id.Connection  = (OracleConnection)conn;
                                            //Input param
                                            cmd_emp_id.Parameters.Add("p_scheme_fund_id", OracleDbType.Varchar2, ParameterDirection.Input).Value = Scheme_fund_id;
                                            //Output param
                                            OracleParameter count = new OracleParameter("p_result", OracleDbType.Decimal, 100, ParameterDirection.Output);
                                            cmd_emp_id.Parameters.Add(count);
                                            cmd_emp_id.ExecuteNonQuery();
                                            string mtotal = (count.Value).ToString();
                                            int    total  = Convert.ToInt32(mtotal);
                                            if (total <= 0)
                                            {
                                                X.Mask.Hide();
                                                error_nos += 1;
                                                erroor_msg = erroor_msg + "Scheme fund does not exist for . - " + employee_Repo.First_Name + " " + employee_Repo.Surname + Environment.NewLine;
                                            }
                                        }
                                        else
                                        {
                                            X.Mask.Hide();
                                            error_nos += 1;
                                            erroor_msg = erroor_msg + "Scheme fund does not exist for . - " + employee_Repo.First_Name + " " + employee_Repo.Surname + Environment.NewLine;
                                        }



                                        //create account now
                                        ////create scheme fund account for employee
                                        decimal successs_1_2            = 0;
                                        string  Employee_Scheme_fund_id = cust_noo + Scheme_fund_id;

                                        //check if ESF ID exist
                                        var param_t = new DynamicParameters();
                                        param_t.Add(name: "p_esf_id", value: Employee_Scheme_fund_id, dbType: DbType.String, direction: ParameterDirection.Input);
                                        param_t.Add(name: "p_result", value: emp_num, dbType: DbType.Decimal, direction: ParameterDirection.Output);
                                        conn.Execute(sql: "SEL_CRM_ESFIDEXIST", param: param_t, commandType: CommandType.StoredProcedure);
                                        decimal t_res = param_t.Get <decimal>("p_result");
                                        if (t_res > 0)
                                        {
                                            X.Mask.Hide();
                                            X.Msg.Show(new MessageBoxConfig
                                            {
                                                Title   = "Error",
                                                Message = "Employer Scheme already exist for " + employee_Repo.First_Name + " " + employee_Repo.Surname,
                                                Buttons = MessageBox.Button.OK,
                                                Icon    = MessageBox.Icon.ERROR,
                                                Width   = 350
                                            });
                                            return(false);
                                        }

                                        param.Add(name: "p_emp_schme_fund_id", value: Employee_Scheme_fund_id, dbType: DbType.String, direction: ParameterDirection.Input);
                                        param.Add(name: "p_scheme_fund_id", value: Scheme_fund_id, dbType: DbType.String, direction: ParameterDirection.Input);
                                        param.Add(name: "p_custNo", value: cust_noo, dbType: DbType.String, direction: ParameterDirection.Input);
                                        param.Add(name: "p_BatchNo", value: batchno, dbType: DbType.String, direction: ParameterDirection.Input);
                                        param.Add(name: "p_MakeId", value: GlobalValue.User_ID, dbType: DbType.String, direction: ParameterDirection.Input);
                                        param.Add(name: "p_MakeDate", value: GlobalValue.Scheme_Today_Date, dbType: DbType.DateTime, direction: ParameterDirection.Input);
                                        param.Add(name: "p_result", value: successs_1_2, dbType: DbType.Decimal, direction: ParameterDirection.Output);

                                        conn.Execute(sql: "ADD_CRM_REMITSCHEMEFUNDBNEW", param: param, commandType: CommandType.StoredProcedure);
                                    } //end if for create_new_or_justacct =2
                                }     ///while


                                ts.Complete();
                                // this.GetCmp<Window>("loading_EmpBatch").Hide();
                                return(true);
                            }
                            catch (TransactionException transexeption)
                            {
                                X.Mask.Hide();
                                X.Msg.Show(new MessageBoxConfig
                                {
                                    Title   = "Error",
                                    Message = transexeption.ToString(),
                                    Buttons = MessageBox.Button.OK,
                                    Icon    = MessageBox.Icon.ERROR,
                                    Width   = 350
                                });

                                errormsg = transexeption.ToString();
                                return(false);
                                //throw;
                            }
                            catch (System.Exception ex)
                            {
                                string ora_code = ex.Message.Substring(0, 9);
                                if (ora_code == "ORA-20000")
                                {
                                    ora_code = "Record already exist. Process aborted..";
                                }
                                else if (ora_code == "ORA-20100")
                                {
                                    ora_code = "Record is uniquely defined in the system. Process aborted..";
                                }
                                else
                                {
                                    ora_code = ex.ToString();
                                }
                                X.Mask.Hide();
                                X.Msg.Show(new MessageBoxConfig
                                {
                                    Title   = "Error",
                                    Message = ora_code,
                                    Buttons = MessageBox.Button.OK,
                                    Icon    = MessageBox.Icon.INFO,
                                    Width   = 350
                                });
                                // logger.WriteLog(ex.Message);

                                return(false);
                            }
                            finally
                            {
                                ts.Dispose();
                                //a_value = a_value;
                                if (conn.State == ConnectionState.Open)
                                {
                                    conn.Close();
                                }

                                if (con_ex.State == ConnectionState.Open)
                                {
                                    con_ex.Close();
                                }
                            }
                        }  //end for transscope
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                string ora_code = ex.Message.Substring(0, 9);
                if (ora_code == "ORA-20000")
                {
                    ora_code = "Record already exist. Process aborted..";
                }
                else if (ora_code == "ORA-20100")
                {
                    ora_code = "Record is uniquely defined in the system. Process aborted..";
                }
                else
                {
                    ora_code = ex.ToString();
                }
                X.Mask.Hide();
                X.Msg.Show(new MessageBoxConfig
                {
                    Title   = "Error",
                    Message = ora_code,
                    Buttons = MessageBox.Button.OK,
                    Icon    = MessageBox.Icon.INFO,
                    Width   = 350
                });
                // logger.WriteLog(ex.Message);

                return(false);
            }
        }
示例#9
0
        public ActionResult SendEmailIndi(crm_EmployeeRepo employeeRepo)
        {
            try
            {
                if (String.IsNullOrEmpty(employeeRepo.Scheme_Id))

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

                    return(this.Direct());
                }


                string queryString = "select * from VW_EMPLOYEE_ESF_SCHEME_REPORT where scheme_id = '" + employeeRepo.Scheme_Id + "' and ESF_STATUS = 'ACTIVE'  ";
                //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())
                    {
                        if (string.IsNullOrEmpty((string)reader["MOBILE_NUMBER"]))
                        {
                            employeeRepo.Mobile_Number = "000000000";
                        }
                        else
                        {
                            employeeRepo.Mobile_Number = (string)reader["MOBILE_NUMBER"];
                        }
                        employeeRepo.First_Name = (string)reader["First_Name"];
                        // repo_emplog.Mobile_Number = (string)reader["Mobile_Number"];
                        employeeRepo.Scheme_Name = (string)reader["Scheme_Name"];
                        employeeRepo.Scheme_Id   = (string)reader["Scheme_Id"];
                        //employeeRepo.SEND_SMS = (string)reader["SEND_SMS"];
                        String mcode = (string)reader["CUST_NO"];

                        //if (employeeRepo.SEND_SMS == "YES")
                        //{
                        employeeRepo.Mobile_Number = employeeRepo.Mobile_Number.Replace(" ", string.Empty);
                        if (employeeRepo.Mobile_Number.Length < 9)
                        {
                            employeeRepo.Mobile_Number = "000000000";
                        }

                        //SEND SMS
                        string smsmsg = "Dear " + employeeRepo.First_Name + " , " + employeeRepo.Message + " . Thank you";
                        string fonnum = "233" + employeeRepo.Mobile_Number.Substring(employeeRepo.Mobile_Number.Length - 9, 9);

                        Dictionary <string, string> paramSMS = new Dictionary <string, string>();
                        paramSMS.Add("to", fonnum);
                        paramSMS.Add("text", smsmsg);
                        Request request = new Request
                        {
                            Parameters = paramSMS
                        };

                        var content = Volley.PostRequest(request);
                        //END SEND SMS
                        // }
                    }

                    reader.Close();
                    X.Mask.Hide();

                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Sent",
                        Message = "SMS Successfully Sent to Employees",
                        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 = "SMS traffic issue. Please send again to continue",
                    Buttons = MessageBox.Button.OK,
                    Icon    = MessageBox.Icon.ERROR,
                    Width   = 350
                });
                return(this.Direct());
            }
        }
示例#10
0
        public ActionResult ApprovePendingEmployee(crm_EmployeeRepo setupEmployee)
        {
            try
            {
                //if (ModelState.IsValid)
                //{
                if (string.IsNullOrEmpty(setupEmployee.Employee_Id))
                {
                    X.Mask.Hide();
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Select an employee to approve.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });
                    return(this.Direct());
                }

                //Save new employee
                if (this.employeeRepo.ApprovePendingEmployee(setupEmployee.Employee_Id, setupEmployee.Cust_No, setupEmployee.Scheme_Fund_Id))
                {
                    if (setupEmployee.SEND_SMS == "YES")
                    {
                        if (string.IsNullOrEmpty(setupEmployee.Mobile_Number))
                        {
                            setupEmployee.Mobile_Number = "000000000";
                        }
                        else
                        {
                            setupEmployee.Mobile_Number = setupEmployee.Mobile_Number;
                        }
                        if (setupEmployee.Mobile_Number.Length < 9)
                        {
                            setupEmployee.Mobile_Number = "000000000";
                        }
                        //SEND SMS
                        string smsmsg = "Dear " + setupEmployee.First_Name + ", you have successfully been registered on the " + setupEmployee.Scheme_Name + " with member code " + setupEmployee.Cust_No + ". Thank you";
                        string fonnum = "233" + setupEmployee.Mobile_Number.Substring(setupEmployee.Mobile_Number.Length - 9, 9);

                        Dictionary <string, string> param = new Dictionary <string, string>();
                        param.Add("to", fonnum);
                        param.Add("text", smsmsg);
                        Request request = new Request
                        {
                            Parameters = param
                        };

                        var content = Volley.PostRequest(request);
                        //END SEND SMS
                    }
                    X.Mask.Hide();
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Success",
                        Message = "Employee: " + setupEmployee.Surname + " " + setupEmployee.First_Name + " approved Successfully.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });
                    //clear controls
                    ClearControls();
                    this.GetCmp <Image>("empAppNew_pic1").ImageUrl = "";
                    this.GetCmp <Image>("empAppNew_pic2").ImageUrl = "";
                }
                else
                {
                    X.Mask.Hide();
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Process aborted.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });
                    return(this.Direct());
                }
                Store store = X.GetCmp <Store>("employeeStore");
                store.Reload();

                //}
                //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)
            {
                X.Mask.Hide();
                logger.WriteLog(ex.Message);
                X.Msg.Show(new MessageBoxConfig
                {
                    Title   = "Error",
                    Message = "Process failed -" + ex.Message,
                    Buttons = MessageBox.Button.OK,
                    Icon    = MessageBox.Icon.INFO,
                    Width   = 350
                });
                return(this.Direct());
            }
        }
//status employee
        public ActionResult EmployeeStatus(crm_EmployeeRepo empRepo)
        {
            try
            {
                if (string.IsNullOrEmpty(empRepo.Cust_No))
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Please select employee.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.ERROR,
                        Width   = 350
                    });
                    return(this.Direct());
                }
                if (string.IsNullOrEmpty(empRepo.Cust_Status_New))
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Please select new status.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.ERROR,
                        Width   = 350
                    });
                    return(this.Direct());
                }

                //if (!string.IsNullOrEmpty(empRepo.Scheme_Id))
                //{
                //	GlobalValue.Get_Scheme_Today_Date(empRepo.Scheme_Id);
                //}
                //else
                //{
                //	X.Msg.Show(new MessageBoxConfig
                //	{
                //		Title = "Error",
                //		Message = "Scheme cannot be verified.",
                //		Buttons = MessageBox.Button.OK,
                //		Icon = MessageBox.Icon.INFO,
                //		Width = 350

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

                //}


                employeeRepo.EmployeeStatus(empRepo);
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Success",
                        Message = "Employee Status Successfully Changed.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });

                    //clear controls
                    ClearControls_employeetransfer();
                }
                Store store = X.GetCmp <Store>("employeestatus_empStore");
                store.Reload();

                return(this.Direct());
            }
            catch (Exception ex)
            {
                string ora_code = ex.Message.Substring(0, 9);
                if (ora_code == "ORA-20000")
                {
                    ora_code = "Record already exist. Process aborted..";
                }
                else if (ora_code == "ORA-20100")
                {
                    ora_code = "Record can not be transferred. Process aborted..";
                }
                else
                {
                    ora_code = ex.ToString();
                }
                X.Msg.Show(new MessageBoxConfig
                {
                    Title   = "Error",
                    Message = ora_code,
                    Buttons = MessageBox.Button.OK,
                    Icon    = MessageBox.Icon.INFO,
                    Width   = 350
                });
                return(this.Direct());
            }
        }
        public ActionResult UpdateRecord(crm_EmployeeRepo crmEmployee)
        {
            try
            {
                //if (ModelState.IsValid)
                //{

                crmEmployee.Employee_Photo    = mImage;
                crmEmployee.Employee_Photo_Id = mImage_ID;

                if (string.IsNullOrEmpty(crmEmployee.Employee_Id))
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Select an employee to edit.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });
                    return(this.Direct());
                }

                if (crmEmployee.isValidUpdate(crmEmployee.Employee_Id) == true)
                {
                    X.Mask.Hide();
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Sorry! There is a pending update for this employee. Process aborted.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });
                    return(this.Direct());
                }

                if (string.IsNullOrEmpty(crmEmployee.Employer_Id))
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Employer name is required",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });
                    return(this.Direct());
                }
                if (!string.IsNullOrEmpty(crmEmployee.Mobile_Number))
                {
                    if (Microsoft.VisualBasic.Information.IsNumeric(crmEmployee.Mobile_Number) == false)
                    {
                        X.Msg.Show(new MessageBoxConfig
                        {
                            Title   = "Error",
                            Message = "Primary phone number must be numbers.",
                            Buttons = MessageBox.Button.OK,
                            Icon    = MessageBox.Icon.INFO,
                            Width   = 350
                        });
                        return(this.Direct());
                    }
                }
                if (!string.IsNullOrEmpty(crmEmployee.Father_Phone_Number))
                {
                    if (Microsoft.VisualBasic.Information.IsNumeric(crmEmployee.Father_Phone_Number) == false)
                    {
                        X.Msg.Show(new MessageBoxConfig
                        {
                            Title   = "Error",
                            Message = "Father's phone number must be numbers.",
                            Buttons = MessageBox.Button.OK,
                            Icon    = MessageBox.Icon.INFO,
                            Width   = 350
                        });
                        return(this.Direct());
                    }
                }
                if (!string.IsNullOrEmpty(crmEmployee.Mother_Phone_Number))
                {
                    if (Microsoft.VisualBasic.Information.IsNumeric(crmEmployee.Mother_Phone_Number) == false)
                    {
                        X.Msg.Show(new MessageBoxConfig
                        {
                            Title   = "Error",
                            Message = "Mother's phone number must be numbers.",
                            Buttons = MessageBox.Button.OK,
                            Icon    = MessageBox.Icon.INFO,
                            Width   = 350
                        });
                        return(this.Direct());
                    }
                }
                if (!string.IsNullOrEmpty(crmEmployee.Other_Number))
                {
                    if (Microsoft.VisualBasic.Information.IsNumeric(crmEmployee.Other_Number) == false)
                    {
                        X.Msg.Show(new MessageBoxConfig
                        {
                            Title   = "Error",
                            Message = "Secondary phone number must be numbers.",
                            Buttons = MessageBox.Button.OK,
                            Icon    = MessageBox.Icon.INFO,
                            Width   = 350
                        });
                        return(this.Direct());
                    }
                }
                if (!string.IsNullOrEmpty(crmEmployee.Email_Address))
                {
                    if (Regex.IsMatch(crmEmployee.Email_Address, MatchEmailPattern) == false)
                    {
                        X.Msg.Show(new MessageBoxConfig
                        {
                            Title   = "Error",
                            Message = "Primary email address is not valid.",
                            Buttons = MessageBox.Button.OK,
                            Icon    = MessageBox.Icon.INFO,
                            Width   = 350
                        });
                        return(this.Direct());
                    }
                }
                if (!string.IsNullOrEmpty(crmEmployee.Other_Email_Address))
                {
                    if (Regex.IsMatch(crmEmployee.Other_Email_Address, MatchEmailPattern) == false)
                    {
                        X.Msg.Show(new MessageBoxConfig
                        {
                            Title   = "Error",
                            Message = "Secondary email address is not valid.",
                            Buttons = MessageBox.Button.OK,
                            Icon    = MessageBox.Icon.INFO,
                            Width   = 350
                        });
                        return(this.Direct());
                    }
                }
                if (DateTime.Compare(crmEmployee.Date_Of_Birth, DateTime.Today) >= 0)
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "DOB can not be today or in the future.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });
                    return(this.Direct());
                }


                //update employee record
                if (this.employeeRepo.AddEmployeeRecordToTmp(crmEmployee))
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Success",
                        Message = "Updated Successfully.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });
                    //clear controls
                    ClearControls();
                }
                else
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Process aborted.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });
                    return(this.Direct());
                }
                Store store = X.GetCmp <Store>("employeeStore");
                store.Reload();



                return(this.Direct());
            }
            catch (Exception ex)
            {
                logger.WriteLog(ex.Message);
                X.Msg.Show(new MessageBoxConfig
                {
                    Title   = "Error",
                    Message = "Process failed -" + ex.Message,
                    Buttons = MessageBox.Button.OK,
                    Icon    = MessageBox.Icon.INFO,
                    Width   = 350
                });
                return(this.Direct());
            }
        }
示例#13
0
        public void SendIt2(string from, string pass, string subj, string msg, string to, string smtp, int port, crm_EmployeeRepo employeeRepo, 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;
            }
        }