Esempio n. 1
0
        public void entercopro()
        {
            decimal co_qualifier = decimal.Parse(lsvCopro2.SelectedItems[0].SubItems[3].Text);

            if (co_qualifier > _Total)
            {
                Modaldialog frm = new Modaldialog("จะต้องมียอดซื้อขั้นต่ำ " + co_qualifier.ToString() + " บาท", 2, 2);
                frm.ShowDialog();
            }
            else
            {
                _COID     = int.Parse(lsvCopro2.SelectedItems[0].SubItems[0].Text);
                _CONAME   = lsvCopro2.SelectedItems[0].SubItems[1].Text;
                _COSTATUS = true;
                this.Close();
            }
        }
Esempio n. 2
0
        private void Seach_Data()
        {
            lsvListitem.Visible = false;
            try
            {
                if (txtSearchCard.Text == "")
                {
                    Modaldialog frm = new Modaldialog("กรุณากรอกข้อมูล", 2, 1);
                    frm.ShowDialog();
                    //MessageBox.Show("กรุณากรอกข้อมูล");
                }
                else
                {
                    string type     = cbSearchType.SelectedItem.ToString();
                    string sqlQuery = @"SELECT A.ID,B.CARDID,A.TITLE,A.FULLNAME,A.ADDR_MOBILE ,B.CARDLV,A.ADDR_ROW1,A.ADDR_ROW2,A.ADDR_PROVINCE,A.ADDR_ZIPCODE,A.BIRTHDATE,A.SEX
                                        FROM MAS_CT A
                                        LEFT JOIN MAS_CT_CD B ON A.ID=B.CT_ID
                                        WHERE A.CT_STATUS = 'A' ";
                    string Addition = string.Empty;


                    if (type == "รหัสบัตรสมาชิก")
                    {
                        Addition = " AND B.CARDID = '" + txtSearchCard.Text + "'";
                    }
                    else if (type == "ชื่อลูกค้า")
                    {
                        Addition = " AND A.FULLNAME LIKE '%" + txtSearchCard.Text + "%'";
                    }
                    else if (type == "เบอร์โทรศัพท์")
                    {
                        Addition = " AND A.ADDR_MOBILE = " + txtSearchCard.Text + "'";
                    }
                    else if (type == "บัตรประชาชน")
                    {
                        Addition = " AND A.PEOPLEID = " + txtSearchCard.Text + "'";
                    }
                    sqlQuery += Addition;

                    DSCUSTOMER = GetDataSet(_connLocal_CMDFX, sqlQuery);
                    DataTable dt = DSCUSTOMER.Tables[0];

                    if (dt.Rows.Count > 1)
                    {
                        lsvListitem.Items.Clear();
                        foreach (DataRow Rows in dt.Rows)
                        {
                            ListViewItem lst = new ListViewItem();
                            lst = lsvListitem.Items.Add(Rows["CARDID"].ToString());
                            lst.SubItems.Add(Rows["TITLE"].ToString() + " " + Rows["FULLNAME"].ToString());
                            lst.SubItems.Add(Rows["ADDR_MOBILE"].ToString());
                            lst.SubItems.Add(Rows["CARDLV"].ToString());
                            lst.SubItems.Add(Rows["ID"].ToString());

                            lst.SubItems.Add(Rows["ADDR_ROW1"].ToString());
                            lst.SubItems.Add(Rows["ADDR_ROW2"].ToString());
                            lst.SubItems.Add(Rows["ADDR_PROVINCE"].ToString());
                            lst.SubItems.Add(Rows["ADDR_ZIPCODE"].ToString());
                            lst.SubItems.Add(Rows["BIRTHDATE"].ToString());
                            lst.SubItems.Add(Rows["SEX"].ToString());
                        }

                        lsvListitem.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                        lsvListitem.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
                        lsvListitem.Columns[3].Width = 0;
                        lsvListitem.Columns[4].Width = 0;
                        lsvListitem.Columns[5].Width = 0;
                        lsvListitem.Columns[6].Width = 0;
                        lsvListitem.Columns[7].Width = 0;
                        lsvListitem.Columns[8].Width = 0;
                        lsvListitem.Columns[9].Width = 0;
                        lsvListitem.FullRowSelect    = true;

                        lsvListitem.Visible = true;
                    }
                    else if (dt.Rows.Count == 1)
                    {
                        _CARDID = dt.Rows[0]["CARDID"].ToString();
                        _CT_ID  = dt.Rows[0]["ID"].ToString();
                        _CARDLV = dt.Rows[0]["CARDLV"].ToString();

                        lbd_cardid.Text  = dt.Rows[0]["CARDID"].ToString();
                        lbdFullname.Text = dt.Rows[0]["TITLE"].ToString() + " " + dt.Rows[0]["FULLNAME"].ToString();
                        lbdtel.Text      = dt.Rows[0]["ADDR_MOBILE"].ToString();

                        string cardlv = dt.Rows[0]["CARDLV"].ToString();
                        if (cardlv == "101")
                        {
                            lbdCardlv.Text = "PINK MEMBER";
                        }
                        else if (cardlv == "102")
                        {
                            lbdCardlv.Text = "ROSEGOLD MEMBER";
                        }
                        else if (cardlv == "501")
                        {
                            lbdCardlv.Text = "SILVER MEMBER";
                        }
                        else if (cardlv == "502")
                        {
                            lbdCardlv.Text = "GOLD MEMBER";
                        }
                        else
                        {
                            lbdCardlv.Text = "ไม่มีระดับสมาชิก";
                        }

                        cust.CARDID             = dt.Rows[0]["CARDID"].ToString();
                        cust.CT_ID              = dt.Rows[0]["ID"].ToString();
                        cust.FULLNAME           = dt.Rows[0]["FULLNAME"].ToString();
                        cust.ADDR_ROW1          = dt.Rows[0]["ADDR_ROW1"].ToString();
                        cust.ADDR_ROW2          = dt.Rows[0]["ADDR_ROW2"].ToString();
                        cust.ADDR_PROVINCE      = dt.Rows[0]["ADDR_PROVINCE"].ToString();
                        cust.ADDR_ZIPCODE       = dt.Rows[0]["ADDR_ZIPCODE"].ToString();
                        cust.ADDR_MOBILE        = dt.Rows[0]["ADDR_MOBILE"].ToString();
                        cust.BIRTHDATE          = DateTime.Parse(dt.Rows[0]["BIRTHDATE"].ToString());
                        cust.SEX                = dt.Rows[0]["SEX"].ToString();
                        lklEditcustomer.Visible = true;
                    }
                    else
                    {
                        Modaldialog frm = new Modaldialog("ไม่พบข้อมูลลูกค้า", 1, 1);
                        frm.ShowDialog();
                        //MessageBox.Show("ไม่พบข้อมูล");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                //Modaldialog frm = new Modaldialog(ex.Message, 2);
                //frm.ShowDialog();
                throw;
            }
        }