//[HttpPost]
        //public ActionResult TransactionQuery(string searchkey,DateTime startdate,DateTime enddate)
        //{
        //    if (HttpContext.Session["UID"] == null)
        //    {
        //        return RedirectToAction("Index", "Portal", null);
        //    }


        //    List<mTransaction> Transactions = new List<mTransaction>();

        //    using (Models.MerchantService db = new Models.MerchantService())
        //    {
        //        List<v_Transactions> trans = db.v_Transactions.Where(x => (x.MPU_Merchant_ID.Contains(searchkey) || x.Merchant_Name.Contains(searchkey)) && (x.TrxDate >= startdate && x.TrxDate <= enddate)).ToList();
        //        Transactions = trans.Select(x => new mTransaction { MPU_Merchant_ID = x.MPU_Merchant_ID, Merchant_Name = x.Merchant_Name, CardNo = x.CardNo, CardType = x.CardType, TrxDate = x.TrxDate, TrxAmount = x.TrxAmount, SettAmount = x.SettAmount }).ToList();
        //    }
        //    //mTransaction tran = new mTransaction();
        //    //Transactions = tran.transaction_query(searchkey, startdate, enddate);

        //    return View(Transactions);
        //}

        public PartialViewResult TransactionQueryResult(string searchkey, string startdate, string enddate)
        {
            List <mTransaction> Transactions = new List <mTransaction>();

            if (HttpContext.Session["UID"] == null)
            {
                TempData["ErrorMessage"] = "Session Error";
                TempData.Keep();
                return(PartialView(Transactions));
            }

            try
            {
                DateTime     sDate = Convert.ToDateTime(startdate);
                DateTime     eDate = Convert.ToDateTime(enddate);
                mTransaction T     = new mTransaction();
                Transactions = T.transaction_query(searchkey, sDate, eDate);

                return(PartialView(Transactions));
            }
            catch (Exception ex)
            {
                TempData["ErrorMessage"] = ex.Message;
                TempData.Keep();
                return(PartialView(Transactions));
            }

            //mTransaction tran = new mTransaction();
            //Transactions = tran.transaction_query(searchkey, startdate, enddate);
        }
        public ActionResult Delete(string[] trxid)
        {
            var data = new { status = "", message = "" };

            if (HttpContext.Session["UID"] == null)
            {
                return(RedirectToAction("Index", "Portal", null));
            }

            mUser u = new mUser();

            if (!u.check_user_right(Session["UID"].ToString(), 2))
            {
                return(RedirectToAction("Denied", "Portal", null));
            }

            if (trxid == null)
            {
                data = new { status = "ok", message = "Invalid TRXID" };
            }

            try
            {
                ViewBag.TRXId = trxid;
                string uid = Session["UID"].ToString();
                for (int i = 0; i < trxid.Length; i++)
                {
                    string       tx = trxid[i];
                    mTransaction t  = new mTransaction();
                    t.TrxID = int.Parse(tx);
                    t.Delete(uid);
                }

                var message = String.Format("No of Transactions : {0} had been deleted...", trxid.Length);
                data = new { status = "ok", message = message };
            }
            catch (Exception ex)
            {
                data = new { status = "ok", message = "Transaction List is empty or\n" + ex.Message };
            }

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
        internal FileResult TransactionExportToExcel(string searchkey, string startdate, string enddate)
        {
            if (HttpContext.Session["UID"] != null && startdate != null && enddate != null)
            {
                List <mTransaction> srl = new List <mTransaction>();
                mTransaction        sr  = new mTransaction();

                DateTime sdate = Convert.ToDateTime(startdate);
                DateTime edate = Convert.ToDateTime(enddate);
                srl = sr.transaction_query(searchkey, sdate, edate);

                ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
                ExcelPackage   Ep    = new ExcelPackage();
                ExcelWorksheet Sheet = Ep.Workbook.Worksheets.Add("TransactionQuery");
                Sheet.Cells["A1"].Value = "TrxDate";
                Sheet.Cells["B1"].Value = "MID";
                Sheet.Cells["C1"].Value = "Merchant Name";
                Sheet.Cells["D1"].Value = "Card No";
                Sheet.Cells["E1"].Value = "Card Type";
                Sheet.Cells["F1"].Value = "MDR Rate";
                Sheet.Cells["G1"].Value = "Tran Amount";
                Sheet.Cells["H1"].Value = "MDR Value";
                Sheet.Cells["I1"].Value = "Settlement Amount";
                int row = 2;
                foreach (mTransaction item in srl)
                {
                    Sheet.Cells[string.Format("A{0}", row)].Value = item.TrxDate.Value.Date.ToString("MM/dd/yyyy");
                    Sheet.Cells[string.Format("B{0}", row)].Value = item.MPU_Merchant_ID;
                    Sheet.Cells[string.Format("C{0}", row)].Value = item.Merchant_Name;
                    Sheet.Cells[string.Format("D{0}", row)].Value = item.CardNo;
                    Sheet.Cells[string.Format("E{0}", row)].Value = item.CardType;
                    Sheet.Cells[string.Format("F{0}", row)].Value = item.TRXMDRRate;
                    Sheet.Cells[string.Format("G{0}", row)].Value = item.TrxAmount;
                    Sheet.Cells[string.Format("H{0}", row)].Value = item.MDRValue;
                    Sheet.Cells[string.Format("I{0}", row)].Value = item.SettAmount;
                    row++;
                }

                using (ExcelRange rng = Sheet.Cells[string.Format("F{0}:H{1}", 2, row + 1)])
                {
                    rng.Style.Numberformat.Format = "###,###,##0.00";
                }

                Sheet.Cells[string.Format("A{0}:F{1}", row, row)].Merge = true;
                Sheet.Cells[string.Format("A{0}", row)].Value           = "Total";
                Sheet.Cells[string.Format("G{0}", row)].Value           = srl.Sum(i => i.TrxAmount);
                Sheet.Cells[string.Format("H{0}", row)].Value           = srl.Sum(i => i.MDRValue);
                Sheet.Cells[string.Format("I{0}", row)].Value           = srl.Sum(i => i.SettAmount);

                Sheet.Cells["A:AZ"].AutoFitColumns();
                Response.Clear();

                var FileByteArray = Ep.GetAsByteArray();

                return(File(FileByteArray, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", sdate.ToString("MM/dd/yyyy") + "-" + edate.ToString("MM/dd/yyyy") + "_TransactionQuery.xlsx"));
                //Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                //Response.AddHeader("content-disposition", "attachment: filename=" +trxdate.ToString("MM/dd/yyyy")+chkType+ "_SettlementReport.xlsx");
                //Response.BinaryWrite(Ep.GetAsByteArray());
                //Response.End();
            }
            else
            {
                return(File(new byte[0], "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"));
            }
        }
Exemple #4
0
        internal List <mTransaction> ReadJCB_INC(string filepath)
        {
            if (HttpContext.Session["UID"] == null)
            {
                return(new List <mTransaction>());
            }

            List <mTransaction> Tran_List = new List <mTransaction>();
            string error_Lines            = "Terminated!!!\nError : ";

            try
            {
                if (!string.IsNullOrEmpty(filepath))
                {
                    //Get Trx Date
                    string datestr = Path.GetFileName(filepath);

                    string year  = "20" + datestr.Substring(3, 2);
                    string month = datestr.Substring(5, 2);
                    string day   = datestr.Substring(7, 2);

                    DateTime TRXDate = DateTime.ParseExact(year + "-" + month + "-" + day, "yyyy-MM-dd", null);

                    //Read File
                    string[] lines = System.IO.File.ReadAllLines(filepath);

                    foreach (string line in lines)
                    {
                        if (line.Substring(0, 3) == "100")
                        {
                            mTransaction tran = new mTransaction();
                            tran.CardNo = line.Substring(3, 19).Replace(" ", "");
                            //To Get Card Type
                            mCardType cardType = new mCardType();
                            cardType.BINCode = tran.CardNo.Substring(0, 4);
                            tran.CardType    = cardType.get_card_type();

                            tran.ProcessingCode = line.Substring(22, 6);
                            Double decplace_scr = 1;
                            int    dec_place    = int.Parse(line.Substring(52, 1));
                            for (int i = 0; i < dec_place; i++)
                            {
                                decplace_scr = decplace_scr * 10;
                            }

                            tran.SettConversationRate = Convert.ToDouble(line.Substring(53, 9)) / decplace_scr;
                            tran.CurrencyCode         = line.Substring(62, 3);
                            tran.SettCurrencyCode     = line.Substring(65, 3);
                            tran.TerminalID           = line.Substring(132, 8);

                            //This is from raw file
                            //tran.TrxID = 0001;
                            tran.TrxAmount       = Convert.ToDouble(line.Substring(28, 12)) / 100;
                            tran.MPU_Merchant_ID = line.Substring(140, 15);

                            double rate = 0;

                            if (tran.MPU_Merchant_ID.Substring(0, 3) != "202")
                            {
                                //To get mdr rate from db
                                mMerchant merchant = new mMerchant();
                                merchant.MPU_Merchant_ID = tran.MPU_Merchant_ID;
                                rate = merchant.get_mdr_rate_jcbnotonus(merchant);
                                //rate = getMDRrate(mid, "MPU");

                                if (rate == -123)
                                {
                                    // rate -123 means that cannot get merchant's MDR rate or merchant info does not exist
                                    // so we need to block transaction to upload and show warning
                                    Global_Error = true;
                                    error_Lines += merchant.MPU_Merchant_ID + ",";
                                    TempData["MerchantInfoError"] = error_Lines;
                                    TempData.Keep();
                                }

                                tran.TRXMDRRate = rate;
                                tran.MDRValue   = (tran.TrxAmount * rate) / 100;
                                tran.SettAmount = tran.TrxAmount - tran.MDRValue;
                                tran.TrxDate    = TRXDate;
                                tran.TRXRemark  = Session["UID"].ToString();
                                tran.RecordType = "JCB_Not_ONUS";
                                Tran_List.Add(tran);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                TempData["MerchantInfoError"] = ex.Message;
                TempData.Keep();
            }


            return(Tran_List);
        }
Exemple #5
0
        internal List <mTransaction> ReadMPU_BCOM(string filepath)
        {
            if (HttpContext.Session["UID"] == null)
            {
                return(new List <mTransaction>());
            }
            List <mTransaction> Tran_List = new List <mTransaction>();
            string error_Lines            = "Terminated!!! \nError : ";

            try
            {
                if (!string.IsNullOrEmpty(filepath))
                {
                    //Get Trx Date
                    string datestr = Path.GetFileName(filepath);

                    string year  = "20" + datestr.Substring(3, 2);
                    string month = datestr.Substring(5, 2);
                    string day   = datestr.Substring(7, 2);

                    DateTime TRXDate = DateTime.ParseExact(year + "-" + month + "-" + day, "yyyy-MM-dd", null);

                    //Read File
                    string[] lines = System.IO.File.ReadAllLines(filepath);

                    foreach (var line in lines)
                    {
                        string[]     arr  = line.Split(new char[0], StringSplitOptions.RemoveEmptyEntries);
                        mTransaction tran = new mTransaction();
                        tran.CardNo = arr[4].ToString();

                        mCardType cardtype = new mCardType();
                        cardtype.BINCode = tran.CardNo.Substring(0, 4).ToString();
                        tran.CardType    = cardtype.get_card_type();

                        tran.TrxAmount       = Convert.ToDouble(arr[5].ToString()) / 100;
                        tran.MPU_Merchant_ID = arr[12].ToString();
                        tran.ProcessingCode  = arr[19].ToString();
                        tran.TerminalID      = arr[11].ToString();

                        if (tran.ProcessingCode.Length > 3)
                        {
                            tran.ProcessingCode = arr[18].ToString();
                            tran.TerminalID     = arr[15].ToString();
                        }

                        double rate = 0;

                        mMerchant merchant = new mMerchant();
                        merchant.MPU_Merchant_ID = tran.MPU_Merchant_ID;
                        rate = merchant.get_mdr_rate_mpuonus(merchant);

                        if (rate == -123)
                        {
                            // rate -123 means that cannot get merchant's MDR rate or merchant info does not exist
                            // so we need to block transaction to upload and show warning
                            Global_Error = true;
                            error_Lines += merchant.MPU_Merchant_ID + ",";
                            TempData["MerchantInfoError"] = error_Lines;
                            TempData.Keep();
                        }
                        tran.TRXMDRRate = rate;
                        tran.MDRValue   = (tran.TrxAmount * rate) / 100;
                        tran.SettAmount = tran.TrxAmount - tran.MDRValue;
                        tran.TrxDate    = TRXDate;
                        tran.TRXRemark  = Session["UID"].ToString();
                        tran.RecordType = "MPU_ON_US";
                        Tran_List.Add(tran);
                    }
                }
            }
            catch (Exception ex)
            {
                TempData["MerchantInfoError"] = ex.Message;
                TempData.Keep();
            }


            return(Tran_List);
        }