private void initConfig() { fEdit = new Font(mposC.iniC.grdViewFontName, mposC.grdViewFontSize + 5, FontStyle.Regular); fEditB = new Font(mposC.iniC.grdViewFontName, mposC.grdViewFontSize, FontStyle.Bold); C1ThemeController.ApplicationTheme = mposC.iniC.themeApplication; theme1.Theme = C1ThemeController.ApplicationTheme; vneRspPay = new VNEresponsePayment(); vnePRepd = new VNEPaymentPollingResponsePaymentDetail(); lbAmt.Text = ""; lbStatus.Text = ""; //theme1.SetTheme(sB, "BeigeOne"); //foreach (Control c in panel3.Controls) //{ // theme1.SetTheme(c, "Office2013Red"); //} btnPay.Click += BtnPay_Click; btnVoidPay.Click += BtnVoidPay_Click; lbAmt.Click += LbAmt_Click; c1Button1.Click += C1Button1_Click; bg = txtTableCode.BackColor; fc = txtTableCode.ForeColor; ff = txtTableCode.Font; timer = new Timer(); timer.Interval = 5000; timer.Tick += Timer_Tick; timer.Enabled = false; btnVoidPay.Enabled = false; pnVoidPay.Hide(); btnVoidPay.Hide(); initGrf(); setGrf(); }
private void Timer_Tick(object sender, EventArgs e) { //throw new NotImplementedException(); String err = "00"; //throw new NotImplementedException(); btnVoidPay.Enabled = true; pnVoidPay.Show(); btnVoidPay.Show(); listBox1.Items.Add("vneRspPay.id " + vneRspPay.id); VNEPaymentPollingRequest vnePpReq = new VNEPaymentPollingRequest(); vnePRepd = new VNEPaymentPollingResponsePaymentDetail(); vnePpReq.tipo = "2"; vnePpReq.id = vneRspPay.id; vnePpReq.opName = "admin"; try { lbStatus.Text = "สถานะ รอการชำระเงิน"; var baseAddress = "http://" + mposC.iniC.VNEip + mposC.iniC.VNEwebapi; String txtjson = JsonConvert.SerializeObject(vnePpReq, Formatting.Indented); WebClient webClient = new WebClient(); var http = (HttpWebRequest)WebRequest.Create(new Uri(baseAddress)); http.Accept = "application/json"; http.ContentType = "application/json"; http.Method = "POST"; ASCIIEncoding encoding = new ASCIIEncoding(); Byte[] bytes = encoding.GetBytes(txtjson); Stream newStream = http.GetRequestStream(); newStream.Write(bytes, 0, bytes.Length); newStream.Close(); listBox1.Items.Add("รอรับชำระ " + txtjson); err = "01"; var response = http.GetResponse(); err = "02"; var stream = response.GetResponseStream(); var sr = new StreamReader(stream); var content = sr.ReadToEnd(); vnePRep = new VNEPaymentPollingResponse(); dynamic obj = JsonConvert.DeserializeObject(content); err = "03"; listBox1.Items.Add("รอรับชำระ content " + content); vnePRep.id = obj.id; vnePRep.req_status = obj.req_status; vnePRep.tipo = obj.tipo; vnePRep.payment_status = obj.payment_status; //vnePRep.payment_detail = obj.payment_details.toString(); err = "04"; String aaa = String.Concat(obj.payment_details); err = "05"; dynamic obj1 = JsonConvert.DeserializeObject(aaa); err = "06"; vnePRepd.amount = obj1.amount; vnePRepd.inserted = obj1.inserted; vnePRepd.rest = obj1.rest; vnePRepd.status = obj1.status; listBox1.Items.Add("content vnePRepd " + aaa); err = "07"; //listBox1.Items.Add("รอรับชำระ " + vnePpReq.id); //label10.Text = "ID " + vnePRep.id + " amount " + vnePRepd.amount + " status " + vnePRepd.status; //listBox1.Items.Add(content); if (vnePRepd.status.Equals("completed")) { timer.Stop(); mposC.statusVNEPaysuccess = "1"; printOrder(); printBill(); lbStatus.Text = "รับชำระเรียบร้อย "; Close(); } } catch (Exception ex) { listBox1.Items.Add(err + " " + ex.Message); } }