Ejemplo n.º 1
0
        private void SearchMembership(int searchType)
        {
            if (searchType == 1)
            {
                if (txtMembershipCardName.Text == "" || txtMembershipCardName.Text.Length < 1)
                {
                    return;
                }
            }
            else if (searchType == 2)
            {
                if (txtCode.Text == "" || txtCode.Text.Length < 1)
                {
                    return;
                }
            }
            else if (searchType == 3)
            {
                if (txtCustomerName.Text == "" || txtCustomerName.Text.Length < 1)
                {
                    return;
                }
            }
            else if (searchType == 4)
            {
                if (txtPhoneNumber.Text == "" || txtPhoneNumber.Text.Length < 1)
                {
                    return;
                }
            }

            IMembershipDao membershipDao = new MembershipDao();

            try
            {
                List<Membership> membershipList = new List<Membership>();

                Membership membership = new Membership();

                if (searchType == 1)
                {
                    membershipList = membershipDao.GetMembershipByMembershipCardName(txtMembershipCardName.Text);
                }
                else if (searchType == 2)
                {
                    membership = membershipDao.GetMembershipByMembershipCardCode(txtCode.Text);
                    if (membership != null && membership.id>0)
                        membershipList.Add(membership);
                }
                else if (searchType == 2)
                {
                    membership = membershipDao.GetMembershipByCustomerPhone(txtPhoneNumber.Text);
                    if (membership != null && membership.id > 0)
                        membershipList.Add(membership);
                }

                if (membershipList.Count == 1)
                {
                    FillMembership(membershipList[0]);
                }
                else if (membershipList.Count > 1)
                {
                    CMemberShipForm objMemberShipForm = new CMemberShipForm();

                    objMemberShipForm.btnSelect.Visible = true;
                    objMemberShipForm.btnSelect.Location = new Point(654, 452);
                    objMemberShipForm.MembershipListData = membershipList;

                    objMemberShipForm.ISDialogBox = true;
                    objMemberShipForm.AddButton.Visible = false;
                    objMemberShipForm.UpdateButton.Visible = false;
                    objMemberShipForm.DeleteButton.Visible = false;

               //     CFormManager.Forms.Push(this);
              //      this.Hide();

                    objMemberShipForm.ShowDialog(this);

                    if (objMemberShipForm.DialogResult == DialogResult.OK)
                    {
                        FillMembership(objMemberShipForm.membershipData);

                    }
                }

                //CCustomerManager tempCustomerManager = new CCustomerManager();
                //CCustomerInfo tempCustomerInfo = new CCustomerInfo();
                //CResult oResult = tempCustomerManager.GetCustomerInfoByName(txtMembershipCardName.Text);
                //tempCustomerInfo = (CCustomerInfo)oResult.Data;
                //DataTable dtCustomerList = (DataTable)tempCustomerInfo.CustomerDataTable;
                //if (dtCustomerList.Rows.Count > 1)
                //{
                //    CustomerListForm objCustomerList = new CustomerListForm(dtCustomerList);
                //    objCustomerList.ShowDialog(this);
                //}
                //else if (dtCustomerList.Rows.Count == 1)
                //{
                //    string phoneNumber = dtCustomerList.Rows[0]["phone"].ToString();
                //    txtcDescription.Text = phoneNumber;
                //    btnSearchByPhone_Click(sender, e);
                //}
                //else
                //{
                //    MessageBox.Show("No customer has been found", RMSGlobal.MessageBoxTitle,
                //        MessageBoxButtons.OK, MessageBoxIcon.Information);
                //}

            }
            catch (Exception exp)
            {
                Console.Write(exp.Message);
            }
        }
Ejemplo n.º 2
0
 private void functionalButton5_Click(object sender, EventArgs e)
 {
     CMemberShipForm tempCMemberShipForm = new CMemberShipForm();
     tempCMemberShipForm.ShowDialog();
 }