Example #1
0
        private void membershipfunctionalButton_Click(object sender, EventArgs e)
        {
            try
              {

              CMemberShipAddForm tempCustomerInfoForm = new CMemberShipAddForm("Add", null);

              tempCustomerInfoForm.ISSetMemberShipCard = true;
              tempCustomerInfoForm.btnFindCustomer.Visible = false;
              tempCustomerInfoForm.btnSearchByPhone.Visible = false;
              tempCustomerInfoForm.btnSelect.Visible = true;
              tempCustomerInfoForm.FinishButton.Visible = false;

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

             tempCustomerInfoForm.ShowDialog(this);

              if (tempCustomerInfoForm.DialogResult == DialogResult.OK)
              {
                  membership = tempCustomerInfoForm.MembershipData;

                  TotalAmountCalculation();
              }

              }
              catch (Exception exp)
              {
              Console.Write(exp.Message);
              }
        }
Example #2
0
        private void SelectMembership()
        {
            try
            {
                Form tempForm;
                bool isFound = false;
                for (int rowIndex = 0; rowIndex < dgvMembership.Rows.Count; rowIndex++)
                {
                    if (dgvMembership.Rows[rowIndex].Selected == true && dgvMembership.Rows[rowIndex].Cells["id"].Value != null)
                    {
                        long ID = Convert.ToInt64(dgvMembership.Rows[rowIndex].Cells["id"].Value.ToString()); //for phone number

                        membership = membershipDao.GetMembershipByID(ID);

                        this.DialogResult = DialogResult.OK;
                        isFound = true;

                 //       tempForm = CFormManager.Forms.Pop();
              //          tempForm.Show();
                   //     this.Close();

                        //if (tempResult.IsSuccess)
                        //{
                        //    CCustomerInfoForm tempCustomerInfoForm = new CCustomerInfoForm("Update", (CCustomerInfo)tempResult.Data);
                        //    tempCustomerInfoForm.Show();
                        //    CFormManager.Forms.Push(this);
                        //    this.Hide();
                        //}

                        break;
                    }
                }

                if (!isFound)
                {
                    this.DialogResult = DialogResult.No;
               //     tempForm = CFormManager.Forms.Pop();
               //     tempForm.Show();
               //     this.Close();
                }
            }
            catch (Exception exp)
            {
                Console.Write(exp.Message);
            }
        }
Example #3
0
        private void FinishButton_Click(object sender, EventArgs e)
        {
            IMembershipDao membershipDao = new MembershipDao();

            try
            {
                if (CheckEmpty())
                {
                    return;
                }

                if (isModify)
                {
                    membership = txtTitle.Tag as Membership;
                }
                else
                {
                    membership = new Membership();
                    membership.issueDate = System.DateTime.Now;
                }

                if (txtCustomerName.Tag != null)
                {
                    membership.customerID = (txtCustomerName.Tag as CCustomerInfo).CustomerID;
                }

                if (!isModify)
                {
                    if (txtCustomerName.Tag == null || membership.customerID == 0)
                    {
                        MessageBox.Show("Please select the customer");
                        return;
                    }
                }

                membership.customerName = txtCustomerName.Text;
                membership.customerPhone = txtPhoneNumber.Text;

                if (txtMembershipCardName.Tag != null)
                {
                    membership.mebershipCardID = (txtMembershipCardName.Tag as MembershipCard).id;
                }

                membership.membershipCardName = txtMembershipCardName.Text;
                membership.membershipCardType = cmbType.Text;
                membership.startDate = dtpStartDate.Value;
                membership.endDate = dtpEndDate.Value;

                membership.membershipCardTitle = txtTitle.Text;
                membership.membershipCardCode = txtCode.Text;

                membership.point = float.Parse(txtPoint.Text.ToString());
                membership.discountPercentRate = float.Parse(txtDiscountPercentRate.Text.ToString());

                if (rdbActive.Checked)
                {
                    membership.isActive = rdbActive.Checked;
                }
                else if (rdbInActive.Checked)
                {
                    membership.isActive = false;
                }

                if (isModify)
                {
                    membershipDao.UpdateMembership(membership);
                    MessageBox.Show("Membership  " + membership.id + " updated successfully");
                }
                else
                {
                    membershipDao.AddMembership(membership);
                    MessageBox.Show("Membership  " + membership.id + " created successfully");
                }

            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message);
                //Console.Write(exp.Message);
            }
        }
Example #4
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);
            }
        }
Example #5
0
        private void FillMembership(Membership membership)
        {
            if (membership != null)
            {
                txtCustomerName.Text = membership.customerName;
                txtPhoneNumber.Text = membership.customerPhone;

                this.membership = membership;

                txtMembershipCardName.Text = membership.membershipCardName;
                txtTitle.Tag = membership;
                cmbType.Text = membership.membershipCardType;
                dtpStartDate.Value = membership.startDate;
                dtpEndDate.Value = membership.endDate;

                txtPoint.Text = membership.point.ToString();
                txtDiscountPercentRate.Text = membership.discountPercentRate.ToString();

                txtTitle.Text = membership.membershipCardTitle.ToString();
                txtCode.Text = membership.membershipCardCode.ToString();

                if (membership.isActive)
                {
                    rdbActive.Checked = true;
                }
                else
                {
                    rdbInActive.Checked = true;
                }
            }
        }