Exemple #1
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);
                }
            }
        }
        private void ocmSearchCpnGroup_Click(object sender, EventArgs e)
        {
            try
            {
                oFoodLandCallAPI = new cFoodLandCallAPI();
                var tUrl = otbUrl.Text = tC_Url + "CpnSearchByGroup";

                var oCouponReq = new cmlCpnSearchReq();
                oCouponReq.tCML_StmCode   = otbSearchStmCode.Text;
                oCouponReq.tCML_CpnUseSta = ocbSearchCpnSta.Text;
                var oCpnStatusAll = oFoodLandCallAPI.C_GEToDataCpnByGroup(tUrl.Trim(), oCouponReq);
                ogdDataCoupon.DataSource = oCpnStatusAll;
            }
            catch (Exception oEx)
            {
                throw oEx;
            }
        }