Пример #1
0
        public ArrayList GetSearchCustomer(CustomerSearchData cusData)
        { 
            ArrayList arrResult = new ArrayList();
            string whStr = "";
            string sql = "";

            whStr += (cusData.CUSCODE == "" ? "" : " C.CODE = '" + cusData.CUSCODE + "'");
            whStr += (cusData.CUSTYPE == "" ? "" : (whStr == "" ? "" : " AND ") + " C.CUSTOMERTYPE = '" + cusData.CUSTYPE + "'");
            whStr += (cusData.CUSNAME == "" ? "" : (whStr == "" ? "" : " AND ") + " UPPER(C.NAME) LIKE UPPER('%" + cusData.CUSNAME + "%')");
            whStr += (cusData.LASTNAME == "" ? "" : (whStr == "" ? "" : " AND " ) + " UPPER(C.LASTNAME) LIKE UPPER('%" + cusData.LASTNAME + "%')");
            whStr += (cusData.MEMBERTYPE == 0 ? "" : (whStr == "" ? "" : " AND ") + " C.MEMBERTYPE = " + cusData.MEMBERTYPE.ToString() + "");
            whStr += (cusData.PROVINCE == 0 ? "" : (whStr == "" ? "" : " AND ") + " C.BILLPROVINCE = " + cusData.PROVINCE.ToString() + "");

            sql = "SELECT C.LOID, C.CODE, C.NAME || ' ' || C.LASTNAME AS CUSNAME, M.NAME AS MEMBERTYPE, C.CUSTOMERTYPE, C.EPDATE, C.PAYMENT";
            sql += " FROM CUSTOMER C LEFT JOIN MEMBERTYPE M ON C.MEMBERTYPE = M.LOID";
            sql += (whStr == "" ? "" : " WHERE" + whStr);
            sql += " ORDER BY C.CODE";
            
            try
            {
                OracleDataReader zRd = OracleDB.ExecQueryCmd(sql);
                arrResult.Clear();
                int i = 1;

                while (zRd.Read())
                {
                    CustomerResultData irData = new CustomerResultData();
                    irData.ORDERNO = i;
                    irData.LOID = zRd["LOID"].ToString();
                    irData.CODE = zRd["CODE"].ToString();
                    irData.CUSNAME = zRd["CUSNAME"].ToString();
                    irData.MEMBERTYPE = zRd["MEMBERTYPE"].ToString();

                    if (zRd["CUSTOMERTYPE"].ToString() == Constz.CustomerType.Personal.Code)
                        irData.CUSTOMERTYPE = Constz.CustomerType.Personal.Name;
                    else if (zRd["CUSTOMERTYPE"].ToString() == Constz.CustomerType.Company.Code)
                        irData.CUSTOMERTYPE = Constz.CustomerType.Company.Name;
                    else if (zRd["CUSTOMERTYPE"].ToString() == Constz.CustomerType.Government.Code)
                        irData.CUSTOMERTYPE = Constz.CustomerType.Government.Name;

                    irData.EPDATE = Convert.ToDateTime(zRd["EPDATE"]).ToString(Constz.DateFormat);

                    if (zRd["PAYMENT"].ToString() == Constz.Payment.Cash.Code)
                        irData.PAYMENT = Constz.Payment.Cash.Name;
                    else if (zRd["PAYMENT"].ToString() == Constz.Payment.CreditCard.Code)
                        irData.PAYMENT = Constz.Payment.CreditCard.Name;
                    else if (zRd["PAYMENT"].ToString() == Constz.Payment.Credit.Code)
                        irData.PAYMENT = Constz.Payment.Credit.Name;

                    arrResult.Add(irData);
                    i += 1;
                }
            }
            catch(Exception ex)
            {
                throw ex;
            }
            return arrResult;
        }
Пример #2
0
    private CustomerSearchData GetSearchData()
    {
        CustomerSearchData cusData = new CustomerSearchData();
        cusData.CUSCODE = txtCusCode.Text.Trim();
        cusData.CUSNAME = txtCusName.Text.Trim();
        cusData.LASTNAME = txtLastName.Text.Trim();

        if (radPersonal.Checked == true)
            cusData.CUSTYPE = Constz.CustomerType.Personal.Code;
        else if (radPrivate.Checked == true)
            cusData.CUSTYPE = Constz.CustomerType.Company.Code;
        else if (radOrganize.Checked == true)
            cusData.CUSTYPE = Constz.CustomerType.Government.Code;

        cusData.MEMBERTYPE = Convert.ToDouble(cmbMemberType.SelectedItem.Value);
        cusData.PROVINCE = Convert.ToDouble(cmbProvince.SelectedItem.Value);
        return cusData;
    }