示例#1
0
        public void query()
        {
            string mobilephone = "";
            string cardno      = "";

            if (string.IsNullOrEmpty(Request["CardNo"]) == false)
            {
                cardno = Request["CardNo"];
            }

            if (string.IsNullOrEmpty(Request["mobile"]) == false)
            {
                mobilephone = Request["mobile"];
            }


            if (mobilephone.Length > 0)
            {
                if (IsPhoneNumber(mobilephone) == false)
                {
                    ResultLabel.Text = string.Format("手機號碼{0}格式輸入錯誤", mobilephone);
                    return;
                }
            }

            //if cardno has value,query by cardno first
            if (!string.IsNullOrEmpty(cardno))
            {
                //Get User phoneNumber by cardNo
                CustData        CD   = new CustData();
                BFCRMWebService crm  = new BFCRMWebService();
                string          cust = crm.GetCustDataJSON("", cardno, "", "", "", "");
                if (!string.IsNullOrEmpty(cust))
                {
                    CD = JsonConvert.DeserializeObject <CustData>(cust);
                }

                if (CD.CustList == null)
                {
                    ResultLabel.Text = string.Format("卡號{0}查無資料", cardno);
                    CardNo.Text      = "";
                    return;
                }

                if (!string.IsNullOrEmpty(CD.CustList[0].MobilePhone))
                {
                    mobilephone = CD.CustList[0].MobilePhone;
                }
            }

            if (string.IsNullOrEmpty(mobilephone))
            {
                ResultLabel.Text = "輸入資料有誤";
                return;
            }

            string sql = Verification.QueryByPhone(mobilephone);

            dt = Utility.getDataTable(sql);
            if (dt.Rows.Count > 0)
            {
                DataColumn column = new DataColumn();
                column.DataType   = Type.GetType("System.String");
                column.ColumnName = "CardNo";
                dt.Columns.Add(column);
            }
            //call  長益CRM
            //多增加卡號
            foreach (DataRow dr in dt.Rows)
            {
                string PapersID = dr["PapersID"].ToString();
                if (string.IsNullOrEmpty(PapersID) == false)
                {
                    string          CardNumber = "";
                    CustData        CD         = new CustData();
                    BFCRMWebService crm        = new BFCRMWebService();
                    string          cust       = crm.GetCustDataJSON("", "", "", PapersID, "", "");
                    if (!string.IsNullOrEmpty(cust))
                    {
                        CD = JsonConvert.DeserializeObject <CustData>(cust);
                        if (CD.RC == "0")
                        {
                            CardNumber = CD.CustList[0].CardNo;
                        }
                        else
                        {
                            CardNumber = CD.RM;
                        }
                    }

                    dr["CardNo"] = CardNumber;
                }
            }

            if (dt.Rows.Count == 0)
            {
                ResultLabel.Text = "查無資料";
            }
            else
            {
                ResultLabel.Text = string.Format("共有{0}筆資料", dt.Rows.Count.ToString());
            }
        }
示例#2
0
        public void QueryByDate(int pageIndex, int pageSize)
        {
            ResultLabel.Text = "";
            if (string.IsNullOrEmpty(StartDate.Text))
            {
                ResultLabel.Text = "開始日期不可以為空";
                return;
            }

            if (string.IsNullOrEmpty(EndDate.Text))
            {
                ResultLabel.Text = "結束日期不可以為空";
                return;
            }

            DateTime startdate = new DateTime();
            DateTime enddate   = new DateTime();

            startdate = DateTime.Parse(StartDate.Text);
            enddate   = DateTime.Parse(EndDate.Text);

            if (startdate > enddate)
            {
                ResultLabel.Text = "開始日期不可小於結束日期";
                return;
            }

            string sql = Verification.QueryByDate(StartDate.Text, EndDate.Text);

            System.Data.DataTable AllTable = Utility.getDataTable(sql);
            pageEnd = (AllTable.Rows.Count - 1) / pageSize + 1;
            dt      = GetPagedTable(AllTable, pageIndex, pageSize);
            if (dt.Rows.Count == 0)
            {
                ResultLabel.Text = "查無資料";
            }
            else
            {
                ResultLabel.Text = string.Format("共有{0}筆資料", AllTable.Rows.Count.ToString());

                DataColumn column = new DataColumn();
                column.DataType   = Type.GetType("System.String");
                column.ColumnName = "CardNo";
                dt.Columns.Add(column);

                foreach (DataRow dr in dt.Rows)
                {
                    string PapersID = dr["PapersID"].ToString();
                    if (string.IsNullOrEmpty(PapersID) == false)
                    {
                        string          CardNumber = "";
                        CustData        CD         = new CustData();
                        BFCRMWebService crm        = new BFCRMWebService();
                        string          cust       = crm.GetCustDataJSON("", "", "", PapersID, "", "");
                        if (!string.IsNullOrEmpty(cust))
                        {
                            CD = JsonConvert.DeserializeObject <CustData>(cust);
                            if (CD.RC == "0")
                            {
                                CardNumber = CD.CustList[0].CardNo;
                            }
                            else
                            {
                                CardNumber = CD.RM;
                            }
                        }

                        dr["CardNo"] = CardNumber;
                    }
                }
            }
        }