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()); } }