Esempio n. 1
0
        //ฟังก์ชัน OverLoad
        /// <summary>
        /// รับข้อมูลในการสร้างคูปองจาก Post แล้วแปลงข้อมูลเป็นJson
        /// </summary>
        /// <param name="ptUrl"></param>
        /// <param name="poCouponReq"></param>
        /// <param name="pnTimeOut"></param>
        /// <returns></returns>
        //public String C_SETtCreateCoupon(string ptUrl, cmlCouponReq poCouponReq, int pnTimeOut)
        //{
        //    try
        //    {
        //        oCouponRes = new cmlCouponRes();
        //        nW_TimeOut = pnTimeOut;
        //        oCouponRes = C_GEToMSgReqCreate(ptUrl, poCouponReq);
        //        switch (oCouponRes.tCML_CpnMSg)
        //        {
        //            case "Add Data Successful": oCouponRes.tCML_CpnMSg = "1"; break;
        //            case "หมายเลขคูปองซ้ำ": oCouponRes.tCML_CpnMSg = "2"; break;
        //        }
        //        return oCouponRes.tCML_CpnMSg;
        //    }
        //    catch (Exception oEx)
        //    {
        //        throw oEx;
        //    }
        //}
        public String C_SETtCreateCoupon(string ptUrl, string ptWhoUpd, string ptWhoIns, string ptStmCode, string ptTmnNum, string ptCpnCode, string ptCpnExp, string ptCpnAmt, int pnTimeOut)
        {
            try
            {
                oCouponReq              = new cmlCouponReq();
                oCouponRes              = new cmlCouponRes();
                oCouponReq.tCML_WhoUpd  = ptWhoUpd;
                oCouponReq.tCML_WhoIns  = ptWhoIns;
                oCouponReq.tCML_StmCode = ptStmCode;
                oCouponReq.tCML_TmnNum  = ptTmnNum;
                oCouponReq.tCML_CpnCode = ptCpnCode;
                oCouponReq.tCML_CpnExp  = ptCpnExp;
                oCouponReq.tCML_CpnAmt  = ptCpnAmt;
                nW_TimeOut              = pnTimeOut;
                oCouponRes              = C_GEToMSgReqCreate(ptUrl, oCouponReq);
                switch (oCouponRes.tCML_CpnMSg)
                {
                case "Add Data Successful": oCouponRes.tCML_CpnMSg = "1"; break;

                case "หมายเลขคูปองซ้ำ": oCouponRes.tCML_CpnMSg = "2"; break;
                }
                return(oCouponRes.tCML_CpnMSg);
            }
            catch (Exception oEx)
            {
                throw oEx;
            }
        }
Esempio n. 2
0
        private void ocmCreate_Click(object sender, EventArgs e)
        {
            oCallAPI = new cCallAPI();

            try
            {
                cmlCouponRes oCouponRes = new cmlCouponRes();
                cmlCouponReq oCouponReq = new cmlCouponReq();

                oCouponReq.tCML_WhoUpd  = otbWhoUpd.Text;
                oCouponReq.tCML_WhoIns  = otbWhoIns.Text;
                oCouponReq.tCML_StmCode = otbStmCode.Text;
                oCouponReq.tCML_TmnNum  = otbTmnNum.Text;
                oCouponReq.tCML_CpnCode = otbCpnCode.Text;
                oCouponReq.tCML_CpnExp  = otbCpnExp.Text;
                oCouponReq.tCML_CpnAmt  = otbCpnAmt.Text;
                // otbUrl.Text = "http://172.16.30.151:9000/api/coupon/Create";
                otbUrl.Text = "http://172.16.30.188:90/api/coupon/Create";
                // otbResult.Text = oCallAPI.C_SETtCreateCoupon(otbUrl.Text, oCouponReq, nW_TimeOut);
                otbResult.Text = oCallAPI.C_SETtCreateCoupon(otbUrl.Text, otbWhoIns.Text, otbWhoIns.Text, otbStmCode.Text, otbTmnNum.Text, otbCpnCode.Text, otbCpnExp.Text, otbCpnAmt.Text, nW_TimeOut);
            }
            catch (Exception oEx)
            {
                MessageBox.Show("wMain : ocmCreate_Click//" + oEx.Message);
            }
        }
Esempio n. 3
0
        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);
            }
        }
Esempio n. 4
0
        public IHttpActionResult POSToCreate([FromBody] cmlCouponReq poPara)
        {
            try
            {
                oC_CouponLog    = new cCouponLog();
                oC_CouponRes    = new cmlCouponRes();
                oC_CouponCreate = new cCouponCreate();
                if (ModelState.IsValid)
                {
                    tC_Message = oC_CouponCreate.c_SETtCouponCreate(poPara);

                    return(Json(new { tcml_CpnMSg = tC_Message }));
                    //  return Json(new { Message = tMessage, AccessToken = this.oAccessToKen.C_GETtGennerateAccessToken(poPara.tcml_WhoIns,5) });
                }
                else
                {
                    log.Warn(ModelState.C_GETtErrorModaleSta());

                    return(Json(ModelState.C_GETtErrorModaleSta()));
                }
            }
            catch (Exception oEx)
            {
                log.Error(cExtensionMessageError.C_GEToErrorException(oEx) + ModelState.C_GETtErrorModaleSta());

                return(Json(new { ModelState = ModelState.C_GETtErrorModaleSta(), Exception = cExtensionMessageError.C_GEToErrorException(oEx) }));
            }
            finally
            {
                oC_CouponLog.CL_SETxCouponLog(poPara, null, oC_CouponRes, tC_Message);
            }
        }
Esempio n. 5
0
 /// <summary>
 /// รับข้อมูลในการสร้างคูปองจาก Post แล้วแปลงข้อมูลเป็นJson
 /// </summary>
 /// <param name="ptUrl"></param>
 /// <param name="poCouponReq"></param>
 /// <returns></returns>
 public cmlCouponRes C_SEToCreateCoupon(string ptUrl, cmlCouponReq poCouponReq)
 {
     try
     {
         var oJsonContent = JsonConvert.SerializeObject(poCouponReq, Formatting.Indented);
         return(C_GETtMSgReq(ptUrl, oJsonContent));
     }
     catch (Exception oEx)
     {
         throw oEx;
     }
 }
Esempio n. 6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="ptUrl"></param>
 /// <param name="poCouponReq"></param>
 /// <returns></returns>
 private cmlCouponRes C_GEToMSgReqCreate(string ptUrl, cmlCouponReq poCouponReq)
 {
     try
     {
         oCouponRes = new cmlCouponRes();
         var tJsonCouponReq = JsonConvert.SerializeObject(poCouponReq, 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);
     }
 }
Esempio n. 7
0
        private void ocmCreate_Click(object sender, EventArgs e)
        {
            try
            {
                oFoodLandCallAPI = new cFoodLandCallAPI();
                cmlCouponRes oCouponRes = new cmlCouponRes();
                cmlCouponReq oCouponReq = new cmlCouponReq();
                otbUrl.Text             = tC_Url + "Create";
                oCouponReq.tCML_WhoUpd  = otbWhoUpd.Text;
                oCouponReq.tCML_WhoIns  = otbWhoIns.Text;
                oCouponReq.tCML_StmCode = otbStmCode.Text;
                oCouponReq.tCML_TmnNum  = otbTmnNum.Text;
                oCouponReq.tCML_CpnCode = otbCpnCode.Text;
                oCouponReq.tCML_CpnExp  = otbCpnExp.Text;
                oCouponReq.tCML_CpnAmt  = otbCpnAmt.Text;

                oCouponRes     = oFoodLandCallAPI.C_SEToCreateCoupon(otbUrl.Text.Trim(), oCouponReq);
                otbResult.Text = oCouponRes.tCML_CpnMSg;
            }
            catch (Exception oEx)
            {
                MessageBox.Show("wMain : ocmCreate_Click//" + oEx.Message);
            }
        }
Esempio n. 8
0
        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);
            }
        }
Esempio n. 9
0
        /// <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
            {
            }
        }