Exemplo n.º 1
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());
            }
        }
        public ActionResult Approve_Pending_Batch(crm_EmployeeBatchLogRepo repo_emplog)
        {
            try
            {
                if (!string.IsNullOrEmpty(repo_emplog.Batch_No))
                {
                    //check if pending list exist for employer
                    var app = new AppSettings();
                    con = app.GetConnection();
                    var     param_k = new DynamicParameters();
                    decimal emp_num = 0;
                    param_k.Add(name: "p_employer_id", value: repo_emplog.Employer_Id, dbType: DbType.String, direction: ParameterDirection.Input);
                    param_k.Add(name: "p_status", value: "PENDING", dbType: DbType.String, direction: ParameterDirection.Input);
                    param_k.Add(name: "p_result", value: emp_num, dbType: DbType.Decimal, direction: ParameterDirection.Output);
                    con.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 does not exists for this employer." + Environment.NewLine + ".Proces aborted",
                            Buttons = MessageBox.Button.OK,
                            Icon    = MessageBox.Icon.ERROR,
                            Width   = 350
                        });
                        return(this.Direct());
                    }

                    if (employee_repo.Approve_BatchEmployee_Pending(repo_emplog))
                    {
                        //SEND SMS
                        string queryString = "select * from vw_crm_employee where batch_no = '" + repo_emplog.Batch_No + "' ";

                        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"]))
                                {
                                    repo_emplog.Mobile_Number = "000000000";
                                }
                                else
                                {
                                    repo_emplog.Mobile_Number = (string)reader["Mobile_Number"];
                                }
                                repo_emplog.First_Name = (string)reader["First_Name"];
                                // repo_emplog.Mobile_Number = (string)reader["Mobile_Number"];
                                repo_emplog.Scheme_Name   = (string)reader["Scheme_Name"];
                                repo_emplog.Employer_Name = (string)reader["Employer_Name"];
                                repo_emplog.SEND_SMS      = (string)reader["SEND_SMS"];
                                String mcode = (string)reader["CUST_NO"];

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

                                    //SEND SMS
                                    string smsmsg = "Dear " + repo_emplog.First_Name + ", you have successfully been registered on the " + repo_emplog.Scheme_Name + " with memeber code " + mcode + ". Thank you";
                                    string fonnum = "233" + repo_emplog.Mobile_Number.Substring(repo_emplog.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();
                        }

                        //SEND SMS



                        X.Mask.Hide();
                        ClearControls();
                        X.Msg.Show(new MessageBoxConfig
                        {
                            Title   = "Success",
                            Message = "Employee batch upload approved successfully.",
                            Buttons = MessageBox.Button.OK,
                            Icon    = MessageBox.Icon.INFO,
                            Width   = 350
                        });
                        return(this.Direct());
                    }
                    return(this.Direct());
                }
                else
                {
                    X.Mask.Hide();
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Select a batch to approve.", // " Insufficient data. Operation Aborted",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.ERROR,
                        Width   = 350
                    });
                    return(this.Direct());
                }

                //return this.Direct();
            }
            catch (Exception ex)
            {
                X.Mask.Hide();
                X.Msg.Show(new MessageBoxConfig
                {
                    Title   = "Error",
                    Message = ex.ToString(),
                    Buttons = MessageBox.Button.OK,
                    Icon    = MessageBox.Icon.ERROR,
                    Width   = 350
                });
                return(this.Direct());
            }
        }
Exemplo n.º 3
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());
            }
        }
// send batch id SMS
        public ActionResult Sms_Batch(crm_EmployeeBatchLogRepo repo_emplog)
        {
            try
            {
                //SEND SMS
                string queryString = "select * from vw_crm_employee where employer_id = '000438'";

                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"]))
                        {
                            repo_emplog.Mobile_Number = "000000000";
                        }
                        else
                        {
                            repo_emplog.Mobile_Number = (string)reader["Mobile_Number"];
                        }
                        repo_emplog.First_Name = (string)reader["First_Name"];
                        // repo_emplog.Mobile_Number = (string)reader["Mobile_Number"];
                        repo_emplog.Scheme_Name   = (string)reader["Scheme_Name"];
                        repo_emplog.Employer_Name = (string)reader["Employer_Name"];
                        String mcode = (string)reader["CUST_NO"];

                        if (repo_emplog.Mobile_Number.Length < 9)
                        {
                            repo_emplog.Mobile_Number = "000000000";
                        }

                        //SEND SMS
                        string smsmsg = "Dear " + repo_emplog.First_Name + ", due to a system upgrade to improve service, you have been assigned a new Member ID " + mcode + ". Kindly quote this Member ID in addition to your full name anytime you make payment. EveryDay Pensions: A cedi today, a million tomorrow. ";
                        string fonnum = "233" + repo_emplog.Mobile_Number.Substring(repo_emplog.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();
                    //ClearControls();
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Success",
                        Message = "successfully.",
                        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 = ex.ToString(),
                    Buttons = MessageBox.Button.OK,
                    Icon    = MessageBox.Icon.ERROR,
                    Width   = 350
                });
                return(this.Direct());
            }
        }
Exemplo n.º 5
0
        public ActionResult ApproveRecord(Remit_PurchaseRepo PurchaseRepo)
        {
            try
            {
                if (string.IsNullOrEmpty(PurchaseRepo.Purchase_Id))
                {
                    X.Mask.Hide();
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Sorry! No 'Purchase' has been selected for approval.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.ERROR,
                        Width   = 350
                    });
                    return(this.Direct());
                }

                // get the pending purchase record
                PurchaseRepo.GetPurchasePendingList();


                //pull cash balance from Employer-Scheme Table
                PurchaseRepo.Cash_Balance = 0;
                PurchaseRepo.Get_Cash_Balance(PurchaseRepo);

                if (PurchaseRepo.Cash_Balance <= 0)
                {
                    X.Mask.Hide();
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Sorry! insufficient Cash in Employer Account.",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });

                    return(this.Direct());
                }

                if (PurchaseRepo.isYearMonthValid(PurchaseRepo) == true)
                {
                    X.Mask.Hide();
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = "Error",
                        Message = "Sorry! Ealier Contributions must be purchased before. Purchase aborted",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO,
                        Width   = 350
                    });

                    return(this.Direct());
                }
                GlobalValue.Get_Scheme_Today_Date(PurchaseRepo.Scheme_Id);
                ///approve pending purchases
                PurchaseRepo.Approve_Unit_Purchases(PurchaseRepo);
                string p_purid = PurchaseRepo.Purchase_Id;
                //ClearControls_Approve();
                //SEND SMS
                string queryString = "select * from VW_SMS_EMP_PURCHASE where PURCHASE_LOG_ID = '" + p_purid + "' ";
                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"]))
                        {
                            employee_repo.Mobile_Number = "000000000";
                        }
                        else
                        {
                            employee_repo.Mobile_Number = (string)reader["Mobile_Number"];
                        }

                        employee_repo.First_Name  = (string)reader["First_Name"];
                        employee_repo.Scheme_Name = (string)reader["Scheme_Name"];
                        employee_repo.SEND_SMS    = (string)reader["SEND_SMS"];
                        decimal  EMPLOYEE_AMT  = (decimal)reader["EMPLOYEE_AMT"];
                        decimal  EMPLOYER_AMT  = (decimal)reader["EMPLOYER_AMT"];
                        decimal  TOTAL_AMT     = (decimal)reader["EMPLOYER_AMT"] + (decimal)reader["EMPLOYEE_AMT"];
                        decimal  EMPLOYEE_UNIT = (decimal)reader["EMPLOYEE_UNITS"];
                        decimal  EMPLOYER_UNIT = (decimal)reader["EMPLOYER_UNITS"];
                        decimal  FMONTH        = (decimal)reader["FOR_MONTH"];
                        decimal  FYEAR         = (decimal)reader["FOR_YEAR"];
                        decimal  UNIT_PRICE    = (decimal)reader["UNIT_PRICE"];
                        int      cFMONTH       = Convert.ToInt32(FMONTH);
                        string   SMONTH        = new DateTime(1900, cFMONTH, 01).ToString("MMMM");
                        string   mcode         = (string)reader["CUST_NO"];
                        DateTime tDate         = ((DateTime)reader["TRANS_DATE"]);
                        string   tDate2        = tDate.ToString("MMMM,dd,yyyy");

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

                            //SEND SMS
                            string smsmsg = "Dear " + employee_repo.First_Name + ", your " + employee_repo.Scheme_Name + " account with member code " + mcode + " was credited with GHc " + TOTAL_AMT + " on " + tDate2 + " for " + SMONTH + "," + FYEAR + ". Thank you.";
                            string fonnum = "233" + employee_repo.Mobile_Number.Substring(employee_repo.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();
                }

                //SEND SMS


                X.Mask.Hide();
                X.Msg.Show(new MessageBoxConfig
                {
                    Title   = "Success",
                    Message = "Purchase Successfully Approved.",
                    Buttons = MessageBox.Button.OK,
                    Icon    = MessageBox.Icon.INFO,
                    Width   = 350
                });
                var pvr = new Ext.Net.MVC.PartialViewResult
                {
                    ViewName = "PurchaseApprovePartial",
                    // Model = PurchaseRepo.GetPurchasePendingList(),
                    ContainerId = "MainArea",
                    RenderMode  = RenderMode.AddTo,
                };
                this.GetCmp <TabPanel>("MainArea").SetLastTabAsActive();
                return(pvr);
                // return this.Direct();
            }
            catch (Exception ex)
            {
                X.Mask.Hide();
                string ora_code = ex.Message.Substring(0, 9);
                if (ora_code == "ORA-20000")
                {
                    ora_code = "Could not complete approval process. Process aborted.";
                }
                else if (ora_code == "ORA-20100")
                {
                    ora_code = "Could not complete approval process. 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());
            }
        }