Exemplo n.º 1
0
 private void ocmGetAllCoupon_Click(object sender, EventArgs e)
 {
     try
     {
         oFoodLandCallAPI = new cFoodLandCallAPI();
         var tUrl          = otbUrl.Text = tC_Url + "CpnStatusAll";
         var oCpnStatusAll = oFoodLandCallAPI.C_GEToDataCpnStatusAll(tUrl.Trim());
         ogdDataCoupon.DataSource = oCpnStatusAll;
     }
     catch (Exception oEx)
     {
         MessageBox.Show("wMain : ocmGetAllCoupon_Click//" + oEx.Message);
     }
 }
Exemplo n.º 2
0
        private void W_GETxSearchCpnGroup()
        {
            try
            {
                oFoodLandCallAPI = new cFoodLandCallAPI();
                var oCouponReq = new cmlCpnSearchReq
                {
                    tCML_StmCode   = otbSearchStmCode.Text,
                    tCML_CpnUseSta = tSearchCpnSta
                };
                if (oCouponReq.tCML_CpnUseSta.Equals("ทั้งหมด"))
                {
                    string tUrl = tC_Url + "CpnStatusAll";
                    oCpnData = oFoodLandCallAPI.C_GEToDataCpnStatusAll(tUrl.Trim());
                }
                else if (oCouponReq.tCML_CpnUseSta.Equals("NULL"))
                {
                    oCouponReq.tCML_CpnUseSta = "";
                    string tUrl = tC_Url + "CpnSearchByGroup";
                    oCpnData = oFoodLandCallAPI.C_GEToDataCpnByGroup(tUrl.Trim(), oCouponReq);
                }
                else
                {
                    string tUrl = tC_Url + "CpnSearchByGroup";
                    oCpnData = oFoodLandCallAPI.C_GEToDataCpnByGroup(tUrl.Trim(), oCouponReq);
                }
            }
            catch (WebException oEx)
            {
                int nResCode = (int)oEx.Status;

                if (oEx.Status == WebExceptionStatus.ProtocolError || oEx.Status == WebExceptionStatus.ConnectFailure || oEx.Status == WebExceptionStatus.KeepAliveFailure)
                {
                    var response = oEx.Response as HttpWebResponse;
                    if (response != null)
                    {
                        nResCode = (int)response.StatusCode;
                        if (nResCode == 500)
                        {
                            MessageBox.Show("wMain : W_GETxSearchCpnGroup ///" + oEx.Message + "ไม่สามารถติดต่อฐานข้อมูลได้ หรือฐานข้อมูลไม่ถูกต้อง กรุณาตรวจสอบการตั้งค่า");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("wMain : W_GETxSearchCpnGroup ///" + oEx.Message);
                }
            }
        }