/// <summary> /// ขาใช้คูปอง Sale /Refund /Void /// </summary> /// <param name="ptUrl"></param> /// <param name="ptCpnCode"></param> /// <param name="pnTimeOut"></param> /// <returns></returns> public String C_SETtUseCoupon(string ptUrl, string ptCpnCode, int pnTimeOut) { // String[] aCouponRes; try { nW_TimeOut = pnTimeOut; oCouponRes = new cmlCouponRes(); oCouponCode = new cmlCouponCode { tCML_CpnCode = ptCpnCode }; oCouponRes = C_GEToMSgReq(ptUrl, oCouponCode); //aCouponRes = new String[] { oCouponRes.tCML_StatusCode , oCouponRes.tCML_StatusDescTH // , oCouponRes.tCML_StatusDescEN , oCouponRes.tCML_PrintDesc // , oCouponRes.tCML_RefCode , oCouponRes.tCML_TranDateTime , oCouponRes.tCML_CpnAmt ,oCouponRes.tCML_CpnMSg}; //return aCouponRes; // Arrey var tResult = oCouponRes.tCML_StatusCode + ";" + oCouponRes.tCML_StatusDescTH + ";" + oCouponRes.tCML_StatusDescEN + ";" + oCouponRes.tCML_PrintDesc + ";" + oCouponRes.tCML_RefCode + ";" + oCouponRes.tCML_TranDateTime + ";" + oCouponRes.tCML_CpnAmt + ";" + oCouponRes.tCML_CpnMSg; return(tResult); // String } catch (Exception oEx) { throw oEx; } }
public DataTable C_GEToDataCpnCode(cmlCouponCode poCouponCode) { StringBuilder oSql; try { oSql = new StringBuilder(); if (poCouponCode.tCML_CpnCode != "") { oSql.AppendLine("SELECT FTStmCode"); oSql.AppendLine(",FTTmnNum"); oSql.AppendLine(",FDDateIns"); oSql.AppendLine(",FTCpnCode"); oSql.AppendLine(",FCCpnAmt"); oSql.AppendLine(",FDCpnExp"); oSql.AppendLine(",FTCpnUseSta"); oSql.AppendLine(",FTWhoIns"); oSql.AppendLine("FROM TPSTCpnStatus "); oSql.AppendLine("WHERE FTCpnCode = '" + poCouponCode.tCML_CpnCode + "'"); oSql.AppendLine("ORDER BY FDDateUpd DESC "); var oDataCpn = cCNSP.SP_GEToDbTbl(oSql.ToString()); return(oDataCpn); } else { return(null); } } catch (SqlException oEx) { throw oEx; } }
public IHttpActionResult POSToSale([FromBody] cmlCouponCode poPara) { try { oC_CouponRes = new cmlCouponRes(); oC_CouponReq = new cmlCouponReq(); oC_CouponSale = new cCouponSale(); oC_CouponLog = new cCouponLog(); if (ModelState.IsValid) { oC_CouponRes = oC_CouponSale.c_CHKoCouponSale(poPara); return(Json(oC_CouponRes)); } else { return(Json(oC_CouponRes)); } } catch (Exception oEx) { log.Error(cExtensionMessageError.C_GEToErrorException(oEx)); return(Json(new { ModelState = ModelState.C_GETtErrorModaleSta(), Exception = cExtensionMessageError.C_GEToErrorException(oEx) })); } finally { oC_CouponLog.CL_SETxCouponLog(oC_CouponReq, poPara, oC_CouponRes, null); } }
private void ocmRefund_Click(object sender, EventArgs e) { oCallAPI = new cCallAPI(); try { cmlCouponCode oCouponCode = new cmlCouponCode(); otbUrl.Text = "http://172.16.30.188:90/api/coupon/Refund"; oCouponCode.tCML_CpnCode = otbSendCoupon.Text; otbMsgError.Text = oCallAPI.C_SETtUseCoupon(otbUrl.Text, oCouponCode.tCML_CpnCode, nW_TimeOut); // aCouponRes = oCallAPI.C_SETaUseCoupon(otbUrl.Text, oCouponCode.tCML_CpnCode, nW_TimeOut); //otbStatusCode.Text = aCouponRes[0]; //otbStatusDescTH.Text = aCouponRes[1]; //otbStatusDescEN.Text = aCouponRes[2]; //otbPrintDesc.Text = aCouponRes[3]; //otbRefCode.Text = aCouponRes[4]; //otbTranDateTime.Text = aCouponRes[5]; //otbCpnAmtRes.Text = aCouponRes[6]; //otbMsgError.Text = aCouponRes[7]; } catch (Exception oEx) { MessageBox.Show("wMain : ocmRefund_Click//" + oEx.Message); } }
/// <summary> /// ยกเลิกหมายเลขคูปอง /// </summary> /// <param name="poPara"></param> /// <returns></returns> public cmlCouponRes c_SEToCouponVoid(cmlCouponCode poPara) { cmlCouponCode oCouponCode = new cmlCouponCode(); cmlCouponRes oCouponRes = new cmlCouponRes(); oCouponCode = poPara; StringBuilder oSql; try { oSql = new StringBuilder(); oSql.AppendLine("SELECT FTCpnCode"); oSql.AppendLine("FROM TPSTCpnStatus WITH(noLOCK)"); oSql.AppendLine("WHERE FTCpnCode = '" + oCouponCode.tCML_CpnCode + "'"); oSql.AppendLine("AND FTCpnUseSta ='0'"); if (cCNSP.SP_GEToDbTbl(oSql.ToString()).Rows.Count == 0) { log.Info(cCNMS.tMS_NotfoundStatusDescENVoid); oCouponRes.tCML_StatusCode = cCNMS.tMS_NotfoundStatusCodeVoid; oCouponRes.tCML_StatusDescTH = cCNMS.tMS_NotfoundStatusDescTHVoid; oCouponRes.tCML_StatusDescEN = cCNMS.tMS_NotfoundStatusDescENVoid; oCouponRes.tCML_TranDateTime = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"); return(oCouponRes); } else { log.Info(cCNMS.tMS_SuccessStatusDescENVoid); oCouponRes.tCML_StatusCode = cCNMS.tMS_SuccessStatusCodeVoid; oCouponRes.tCML_StatusDescTH = cCNMS.tMS_SuccessStatusDescTHVoid; oCouponRes.tCML_StatusDescEN = cCNMS.tMS_SuccessStatusDescENVoid; oCouponRes.tCML_TranDateTime = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"); oSql = new StringBuilder(); oSql.AppendLine("UPDATE TPSTCpnStatus WITH(ROWLOCK)"); oSql.AppendLine("SET FTCpnUseSta ='2'"); oSql.AppendLine("WHERE FTCpnCode ='" + oCouponCode.tCML_CpnCode + "'"); var nResult = cCNSP.SP_SETnDbTbl(oSql.ToString()); if (nResult > 0) { return(oCouponRes); } else { log.Info(cCNMS.tMS_ValidStatusDescENSale); oCouponRes.tCML_StatusCode = "505"; oCouponRes.tCML_StatusDescTH = "ยกเลิกสถานะคูปองไม่สำเร็จ"; oCouponRes.tCML_StatusDescEN = "Update Failed"; oCouponRes.tCML_CpnAmt = null; oCouponRes.tCML_TranDateTime = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"); return(oCouponRes); } } } catch (SqlException oEx) { log.Error(cExtensionMessageError.C_GEToErrorException(oEx)); throw cExtensionMessageError.C_GEToErrorException(oEx); } }
public DataTable C_GEToDataCpnByCode(string ptUrl, cmlCouponCode poCouponCode) { try { var tJsonContent = JsonConvert.SerializeObject(poCouponCode, Formatting.Indented); var tResult = C_ContWebApi(ptUrl, "POST", tJsonContent); return(JsonConvert.DeserializeObject <DataTable>(tResult)); } catch (Exception oEx) { throw oEx; } }
public HttpResponseMessage GEToDataCpnCode([FromBody] cmlCouponCode poCouponCode) { try { var oDataCpn = oC_DataCpnSearch.C_GEToDataCpnCode(poCouponCode); return(SEToDataTableToJson(oDataCpn)); } catch (WebException oEx) { log.Error(cExtensionMessageError.C_GEToErrorException(oEx)); throw cExtensionMessageError.C_GEToErrorException(oEx); } }
public cmlCouponRes C_SEToCouponSta(string ptUrl, string ptCpnCode) { var oCouponCode = new cmlCouponCode(); try { oCouponCode.tCML_CpnCode = ptCpnCode; var oJsonContent = JsonConvert.SerializeObject(oCouponCode, Formatting.Indented); return(C_GETtMSgReq(ptUrl, oJsonContent)); } catch (Exception oEx) { throw oEx; } }
private void ocmSearchCpnCode_Click(object sender, EventArgs e) { try { oFoodLandCallAPI = new cFoodLandCallAPI(); var tUrl = otbUrl.Text = tC_Url + "CpnSearchByCpnCode"; var oCouponCode = new cmlCouponCode(); oCouponCode.tCML_CpnCode = otbSearchCpnCode.Text; var oCpnStatusAll = oFoodLandCallAPI.C_GEToDataCpnByCode(tUrl.Trim(), oCouponCode); ogdDataCoupon.DataSource = oCpnStatusAll; } catch (Exception oEx) { throw oEx; } }
private void W_GETxSearchCpnByCode() { try { oFoodLandCallAPI = new cFoodLandCallAPI(); var tUrl = tC_Url + "CpnSearchByCpnCode"; var oCouponCode = new cmlCouponCode { tCML_CpnCode = otbSearchCpnCode.Text }; oCpnData = oFoodLandCallAPI.C_GEToDataCpnByCode(tUrl.Trim(), oCouponCode); } catch (Exception oEx) { MessageBox.Show("wMain : W_GETxSearchCpnByCode ///" + oEx.Message); } }
/// <summary> /// ส่งข้อมูลที่เป็นJson แล้วรับค่า Respond กลับมา /// </summary> /// <param name="ptUrl"></param> /// <param name="tJsonContent"></param> /// <returns></returns> private cmlCouponRes C_GEToMSgReq(string ptUrl, cmlCouponCode poCouponCode) { try { oCouponRes = new cmlCouponRes(); var tJsonCouponReq = JsonConvert.SerializeObject(poCouponCode, Formatting.Indented); var aJsonCouponReq = Encoding.UTF8.GetBytes(tJsonCouponReq); var oHttpWebREQ = C_SEToHttpWebRequest(ptUrl, "POST", aJsonCouponReq); oCouponRes = C_GEToHttpWebResponse(oHttpWebREQ); return(oCouponRes); } catch (WebException oEx) { oCouponRes.tCML_CpnMSg = "404"; return(oCouponRes); } }
public void CL_SETxCouponLog(cmlCouponReq poCouponReq, cmlCouponCode poCouponCode, cmlCouponRes poCouponRes, string ptMessage) { StringBuilder oSql; string tCouponReq; string tCouponRes; try { if (poCouponReq == null) { tCouponReq = new JavaScriptSerializer().Serialize(poCouponCode); } else { tCouponReq = new JavaScriptSerializer().Serialize(poCouponReq); } if (ptMessage == null) { tCouponRes = new JavaScriptSerializer().Serialize(poCouponRes); } else { tCouponRes = new JavaScriptSerializer().Serialize(ptMessage); } oSql = new StringBuilder(); oSql.AppendLine("INSERT INTO TPSTLogPromoCpn"); oSql.AppendLine("("); oSql.AppendLine("FDDateIns"); oSql.AppendLine(",FTTimeIns"); oSql.AppendLine(",FTWhoIns"); oSql.AppendLine(",FTRemark"); oSql.AppendLine(",FTStmCode"); oSql.AppendLine(",FTTmnNum"); oSql.AppendLine(",FTLogCode"); oSql.AppendLine(",FTShdTransNo"); oSql.AppendLine(",FTShdTransType"); oSql.AppendLine(",FTServiceName"); oSql.AppendLine(",FTReqPara"); oSql.AppendLine(",FTResPara"); oSql.AppendLine(",FTStatusCode"); oSql.AppendLine(",FTStatusDescTH"); oSql.AppendLine(",FTStatusDescEN"); oSql.AppendLine(",FTPrintDesc"); oSql.AppendLine(",FTRefCode"); oSql.AppendLine(",FTTranDateTime"); oSql.AppendLine(")"); oSql.AppendLine("VALUES"); oSql.AppendLine("("); oSql.AppendLine("CONVERT([VARCHAR](10),GETDATE(),(121))"); oSql.AppendLine(",CONVERT(VARCHAR(8),GETDATE(),108)"); oSql.AppendLine(",'admin'"); oSql.AppendLine(",''"); oSql.AppendLine(",'0300'"); oSql.AppendLine(",'" + poCouponReq.tCML_TmnNum + "'"); oSql.AppendLine(",'20170512170500'"); oSql.AppendLine(",'00332'"); oSql.AppendLine(",'01'"); oSql.AppendLine(",'ServiceName'"); oSql.AppendLine(",'" + tCouponReq + "'"); oSql.AppendLine(",'" + tCouponRes + "'"); oSql.AppendLine(",'" + poCouponRes.tCML_StatusCode + "'"); oSql.AppendLine(",'" + poCouponRes.tCML_StatusDescTH + "'"); oSql.AppendLine(",'" + poCouponRes.tCML_StatusDescEN + "'"); oSql.AppendLine(",'" + poCouponRes.tCML_PrintDesc + "'"); oSql.AppendLine(",'" + poCouponRes.tCML_RefCode + "'"); oSql.AppendLine(",'" + poCouponRes.tCML_TranDateTime + "'"); oSql.AppendLine(")"); cCNSP.SP_GEToDbTbl(oSql.ToString()); } catch (SqlException oEx) { log.Error(oEx.Message); } }
/// <summary> /// ตรวจสอบสถานะ Coupon /// </summary> /// <param name="poPara"></param> /// <returns></returns> public cmlCouponRes c_CHKoCouponSale(cmlCouponCode poPara) { cmlCouponCode oCouponCode = new cmlCouponCode(); cmlCouponRes oCouponRes = new cmlCouponRes(); oCouponCode = poPara; DateTime oCoupondate; StringBuilder oSql, oSQL; try { oSQL = new StringBuilder(); oSQL.AppendLine("SELECT FTCpnCode,FCCpnAmt"); oSQL.AppendLine("FROM TPSTCpnStatus WITH(noLOCK)"); oSQL.AppendLine("WHERE FTCpnCode ='" + oCouponCode.tCML_CpnCode + "'"); if (cCNSP.SP_GEToDbTbl(oSQL.ToString()).Rows.Count == 0) { log.Info(cCNMS.tMS_NotfoundStatusDescENSale); oCouponRes.tCML_StatusCode = cCNMS.tMS_NotfoundStatusCodeSale; oCouponRes.tCML_StatusDescTH = cCNMS.tMS_NotfoundStatusDescTHSale; oCouponRes.tCML_StatusDescEN = cCNMS.tMS_NotfoundStatusDescENSale; oCouponRes.tCML_TranDateTime = DateTime.Now.ToString("dd/MM/yyyy "); return(oCouponRes); } else { oSql = new StringBuilder(); oSql.AppendLine("SELECT FTCpnUseSta"); oSql.AppendLine("FROM TPSTCpnStatus WITH(noLOCK)"); oSql.AppendLine("WHERE FTCpnCode ='" + oCouponCode.tCML_CpnCode + "'"); switch (cCNSP.SP_GEToDbTbl(oSql.ToString()).Rows[0]["FTCpnUseSta"].ToString()) { case "0": oSql = new StringBuilder(); oSql.AppendLine("SELECT FDCpnExp"); oSql.AppendLine("FROM TPSTCpnStatus WITH(noLOCK)"); oSql.AppendLine("WHERE FTCpnCode ='" + oCouponCode.tCML_CpnCode + "'"); oCoupondate = DateTime.Parse(cCNSP.SP_GEToDbTbl(oSql.ToString()).Rows[0]["FDCpnExp"].ToString()); if (oCoupondate > DateTime.Now) { log.Info(cCNMS.tMS_ValidStatusDescENSale); oCouponRes.tCML_StatusCode = cCNMS.tMS_ValidStatusCodeSale; oCouponRes.tCML_StatusDescTH = cCNMS.tMS_ValidStatusDescTHSale; oCouponRes.tCML_StatusDescEN = cCNMS.tMS_ValidStatusDescENSale; oCouponRes.tCML_CpnAmt = cCNSP.SP_GEToDbTbl(oSQL.ToString()).Rows[0]["FCCpnAmt"].ToString(); oCouponRes.tCML_TranDateTime = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"); log.Info("UPDATE TPSTCpnStatus = 1"); oSql = new StringBuilder(); oSql.AppendLine("UPDATE TPSTCpnStatus WITH(ROWLOCK)"); oSql.AppendLine("SET FTCpnUseSta ='1'"); oSql.AppendLine("WHERE FTCpnCode ='" + oCouponCode.tCML_CpnCode + "'"); var nResult = cCNSP.SP_SETnDbTbl(oSql.ToString()); if (nResult > 0) { return(oCouponRes); } else { log.Info(cCNMS.tMS_ValidStatusDescENSale); oCouponRes.tCML_StatusCode = "505"; oCouponRes.tCML_StatusDescTH = "ปรับสถานะการใช้คูปองไม่สำเร็จ"; oCouponRes.tCML_StatusDescEN = "Update Failed"; oCouponRes.tCML_CpnAmt = null; oCouponRes.tCML_TranDateTime = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"); return(oCouponRes); } } else { log.Info(cCNMS.tMS_ExpiredStatusDescENSale); oCouponRes.tCML_StatusCode = cCNMS.tMS_ExpiredStatusCodeSale; oCouponRes.tCML_StatusDescTH = cCNMS.tMS_ExpiredStatusDescTHSale; oCouponRes.tCML_StatusDescEN = cCNMS.tMS_ExpiredStatusDescENSale; oCouponRes.tCML_CpnAmt = cCNSP.SP_GEToDbTbl(oSQL.ToString()).Rows[0]["FCCpnAmt"].ToString(); oCouponRes.tCML_TranDateTime = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"); return(oCouponRes); } case "1": log.Info(cCNMS.tMS_UsedStatusDescENSale); oCouponRes.tCML_StatusCode = cCNMS.tMS_UsedStatusCodeSale; oCouponRes.tCML_StatusDescTH = cCNMS.tMS_UsedStatusDescTHSale; oCouponRes.tCML_StatusDescEN = cCNMS.tMS_UsedStatusDescENSale; oCouponRes.tCML_CpnAmt = cCNSP.SP_GEToDbTbl(oSQL.ToString()).Rows[0]["FCCpnAmt"].ToString(); oCouponRes.tCML_TranDateTime = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"); return(oCouponRes); case "2": log.Info(cCNMS.tMS_UsedStatusDescENSale); oCouponRes.tCML_StatusCode = cCNMS.tMS_VoidStatusCodeSale; oCouponRes.tCML_StatusDescTH = cCNMS.tMS_VoidStatusDescTHSale; oCouponRes.tCML_StatusDescEN = cCNMS.tMS_VoidStatusDescENSale; oCouponRes.tCML_CpnAmt = cCNSP.SP_GEToDbTbl(oSQL.ToString()).Rows[0]["FCCpnAmt"].ToString(); oCouponRes.tCML_TranDateTime = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"); return(oCouponRes); } } return(oCouponRes); } catch (SqlException oEx) { log.Error(cExtensionMessageError.C_GEToErrorException(oEx)); throw cExtensionMessageError.C_GEToErrorException(oEx); } }
/// <summary> /// สร้าง Coupon /// </summary> /// <param name="poPara"></param> /// <returns></returns> public string c_SETtCouponCreate(cmlCouponReq poPara) { cmlCouponReq oCouponReq = new cmlCouponReq(); cmlCouponCode coCouponCode = new cmlCouponCode(); StringBuilder oSql; string tCpnExp; string CpnUseSta = "0"; DateTime dCpnExp; try { oCouponReq = poPara; //tDateUpd = DateTime.Now.ToString("yyyy/MM/dd"); //tDateIns = DateTime.Now.ToString("yyyy/MM/dd"); //tTimeUpd = DateTime.Now.ToLongTimeString(); //tTimeIns = DateTime.Now.ToLongTimeString(); dCpnExp = DateTime.Parse(oCouponReq.tCML_CpnExp.ToString()); tCpnExp = dCpnExp.ToString("yyyy/MM/dd"); oSql = new StringBuilder(); oSql.AppendLine("INSERT INTO TPSTCpnStatus "); oSql.AppendLine("("); oSql.AppendLine("FDDateUpd"); oSql.AppendLine(",FTTimeUpd"); oSql.AppendLine(",FTWhoUpd"); oSql.AppendLine(",FDDateIns"); oSql.AppendLine(",FTTimeIns"); oSql.AppendLine(",FTWhoIns"); oSql.AppendLine(",FTRemark"); oSql.AppendLine(",FTStmCode"); oSql.AppendLine(",FTTmnNum"); oSql.AppendLine(",FTCpnCode"); oSql.AppendLine(",FTCpnUseSta"); oSql.AppendLine(",FDCpnExp"); oSql.AppendLine(",FCCpnAmt"); oSql.AppendLine(")"); oSql.AppendLine("VALUES"); oSql.AppendLine("("); oSql.AppendLine("CONVERT([VARCHAR](10),GETDATE(),(121))"); oSql.AppendLine(",CONVERT(VARCHAR(8),GETDATE(),108)"); oSql.AppendLine(",'" + oCouponReq.tCML_WhoUpd + "'"); oSql.AppendLine(",CONVERT([VARCHAR](10),GETDATE(),(121))"); oSql.AppendLine(",CONVERT(VARCHAR(8),GETDATE(),108)"); oSql.AppendLine(",'" + oCouponReq.tCML_WhoIns + "'"); oSql.AppendLine(",''"); oSql.AppendLine(",'" + oCouponReq.tCML_StmCode + "'"); oSql.AppendLine(",'" + oCouponReq.tCML_TmnNum + "'"); oSql.AppendLine(",'" + oCouponReq.tCML_CpnCode + "'"); oSql.AppendLine(",'" + CpnUseSta + "'"); oSql.AppendLine(",'" + tCpnExp + "'"); oSql.AppendLine(",'" + oCouponReq.tCML_CpnAmt + "'"); oSql.AppendLine(")"); var nResult = cCNSP.SP_SETnDbTbl(oSql.ToString()); if (nResult > 0) { log.Info(cCNMS.tMS_LogCreateSuccessful); return(cCNMS.tMS_LogCreateSuccessful); } else { log.Info(cCNMS.tMS_LogCreateFalse); return(cCNMS.tMS_LogCreateFalse); } } catch (SqlException oEx) { switch (oEx.Number) { case 2627: return(cCNMS.tMS_LogCreateFalse); } log.Error(cCNMS.tMS_LogCreateFalse); return(cExtensionMessageError.C_GEToErrorException(oEx).ToString()); } finally { } }