internal List <mMerchant> getActiveMerchant(DateTime startdate, DateTime enddate) { if (HttpContext.Session["UID"] == null) { return(new List <mMerchant>()); } List <mMerchant> merchants = new List <mMerchant>(); using (SqlConnection consql = new SqlConnection(ConfigurationManager.ConnectionStrings["MerchantServiceDB"].ConnectionString)) { consql.Open(); SqlCommand cmd = new SqlCommand("sp_r_active_merchant", consql); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@startdate", startdate); cmd.Parameters.AddWithValue("@enddate", enddate); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); for (int i = 0; i < dt.Rows.Count; i++) { mMerchant m = new mMerchant(); m.MPU_Merchant_ID = dt.Rows[i][0].ToString(); m.Merchant_Name = dt.Rows[i][1].ToString(); merchants.Add(m); } } return(merchants); }
public ActionResult UpdateMerchantInfo(string id) { if (HttpContext.Session["UID"] == null) { return(RedirectToAction("Index", "Portal", null)); } mUser u = new mUser(); if (!u.check_user_right(Session["UID"].ToString(), 1)) { return(RedirectToAction("Denied", "Portal", null)); } if (id == null) { return(new HttpStatusCodeResult(statusCode: 400)); } //Business Category for dropdown List <t_BusinessCategory> category_list = new List <t_BusinessCategory>(); using (Models.MerchantService db = new Models.MerchantService()) { category_list = db.t_BusinessCategory.ToList(); } ViewBag.Category = category_list; //Get Merchant Info mMerchant merchantinfo = new mMerchant(); try { using (Models.MerchantService db = new Models.MerchantService()) { t_Merchant_Info merch_info = db.t_Merchant_Info.Where(x => x.MPU_Merchant_ID == id).FirstOrDefault(); merchantinfo.MPU_Merchant_ID = merch_info.MPU_Merchant_ID; merchantinfo.Merchant_Name = merch_info.Merchant_Name; merchantinfo.Merchant_Address = merch_info.Merchant_Address; merchantinfo.Merchant_Email = merch_info.Merchant_Email; merchantinfo.Merchant_Phone = merch_info.Merchant_Phone; merchantinfo.OMPURate = merch_info.OMPURate; merchantinfo.OJCBRate = merch_info.OJCBRate; merchantinfo.OUPIRate = merch_info.OUPIRate; merchantinfo.MPURate = merch_info.MPURate; merchantinfo.JCBRate = merch_info.JCBRate; merchantinfo.UPIRate = merch_info.UPIRate; merchantinfo.Settlement_Acc = merch_info.Settlement_Acc; merchantinfo.SettAccountName = merch_info.SettAccountName; merchantinfo.BusinessCategoryID = merch_info.BusinessCategoryID; } return(View(merchantinfo)); } catch (Exception ex) { TempData["Message"] = ex.Message; TempData.Keep(); return(View()); } }
public ActionResult AddMerchant(mMerchant model) { if (HttpContext.Session["UID"] == null) { return(RedirectToAction("Index", "Portal", null)); } mUser u = new mUser(); if (!u.check_user_right(Session["UID"].ToString(), 1)) { return(RedirectToAction("Denied", "Portal", null)); } try { using (Models.MerchantService db = new Models.MerchantService()) { t_Merchant_Info merchant = new t_Merchant_Info(); merchant.MPU_Merchant_ID = model.MPU_Merchant_ID; merchant.Merchant_Name = model.Merchant_Name; merchant.Merchant_Phone = model.Merchant_Phone; merchant.Merchant_Email = model.Merchant_Email; merchant.Merchant_Address = model.Merchant_Address; merchant.OMPURate = model.OMPURate; merchant.OJCBRate = model.OJCBRate; merchant.OUPIRate = model.OUPIRate; merchant.MPURate = model.MPURate; merchant.JCBRate = model.JCBRate; merchant.UPIRate = model.UPIRate; merchant.Settlement_Acc = model.Settlement_Acc; merchant.SettAccountName = model.SettAccountName; merchant.BusinessCategoryID = model.BusinessCategoryID; merchant.MStatusID = 100; merchant.CreationDate = DateTime.Now.Date; db.t_Merchant_Info.Add(merchant); db.SaveChanges(); TempData["Message"] = "Saved"; TempData.Keep(); } } catch (Exception ex) { TempData["Message"] = ex.InnerException.InnerException.Message; TempData.Keep(); } return(RedirectToAction("CreateMerchant")); }
public ActionResult ViewDetails(string merchantid) { if (HttpContext.Session["UID"] == null) { return(RedirectToAction("Index", "Portal", null)); } mUser u = new mUser(); if (!u.check_user_right(Session["UID"].ToString(), 1)) { return(RedirectToAction("Denied", "Portal", null)); } mMerchant merchant = new mMerchant(); if (merchantid != null) { try { using (Models.MerchantService db = new Models.MerchantService()) { v_Merchant merchant_info = new v_Merchant(); merchant_info = db.v_Merchant.Where(x => x.MPU_Merchant_ID == merchantid).SingleOrDefault(); merchant.MPU_Merchant_ID = merchant_info.MPU_Merchant_ID; merchant.Merchant_Name = merchant_info.Merchant_Name; merchant.Merchant_Address = merchant_info.Merchant_Address; merchant.Merchant_Email = merchant_info.Merchant_Email; merchant.Merchant_Phone = merchant_info.Merchant_Phone; merchant.OMPURate = merchant_info.OMPURate; merchant.OJCBRate = merchant_info.OJCBRate; merchant.OUPIRate = merchant_info.OUPIRate; merchant.MPURate = merchant_info.MPURate; merchant.JCBRate = merchant_info.JCBRate; merchant.UPIRate = merchant_info.UPIRate; merchant.Settlement_Acc = merchant_info.Settlement_Acc; merchant.SettAccountName = merchant_info.SettAccountName; merchant.BusinessCategoryID = merchant_info.BusinessCategoryID; merchant.BusinessCategory = merchant_info.BusinessCategory; } } catch (Exception ex) { TempData["Message"] = ex.Message; TempData.Keep(); } } return(View(merchant)); }
internal JsonResult Terminate(string mid) { string msg = null; var data = Json(new { }); try { mMerchant m = new mMerchant(); m.MPU_Merchant_ID = mid; m.TerminateMerchant(HttpContext.Session["UID"].ToString()); msg = "Terminated"; data = Json(new { success = true, msg = msg }, JsonRequestBehavior.AllowGet); } catch (Exception ex) { data = Json(new { success = true, msg = ex.InnerException.InnerException.Message }, JsonRequestBehavior.AllowGet); } return(data); }
public ActionResult UpdateMerchant(mMerchant model) { if (HttpContext.Session["UID"] == null) { return(RedirectToAction("Index", "Portal", null)); } mUser u = new mUser(); if (!u.check_user_right(Session["UID"].ToString(), 1)) { return(RedirectToAction("Denied", "Portal", null)); } try { using (Models.MerchantService db = new Models.MerchantService()) { //Call Update Method mMerchant merchant = new mMerchant(); merchant.UpdateMerchant(model); TempData["Message"] = "Success"; TempData.Keep(); } } catch (Exception ex) { TempData["Message"] = ex.Message; TempData.Keep(); } //Business Category for dropdown List <t_BusinessCategory> category_list = new List <t_BusinessCategory>(); using (Models.MerchantService db = new Models.MerchantService()) { category_list = db.t_BusinessCategory.ToList(); } ViewBag.Category = category_list; return(RedirectToAction("UpdateMerchantInfo", new { id = model.MPU_Merchant_ID })); }
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); }
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); }