コード例 #1
0
ファイル: CMemberShipAddForm.cs プロジェクト: Jusharra/RMS
        private void SearchMembershipCard(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;
                }
            }

            IMembershipCardDao membershipCardDao = new MembershipCardDao();

            try
            {
                List<MembershipCard> membershipCardList = new List<MembershipCard> ();

                if (searchType == 1)
                {
                    membershipCardList = membershipCardDao.GetAllMembershipCardByName(txtMembershipCardName.Text);
                }
                else
                {
                    membershipCardList = membershipCardDao.GetAllMembershipCardByName(txtCode.Text);
                }

                if (membershipCardList.Count == 1)
                {
                    FillMembershipCard(membershipCardList[0]);
                }
                else if (membershipCardList.Count > 1)
                {
                    CMemberShipCardForm objMemberShipCardForm = new CMemberShipCardForm();

                    objMemberShipCardForm.btnSelect.Visible = true;
                    objMemberShipCardForm.btnSelect.Location = new Point(654, 452);
                    objMemberShipCardForm.MembershipCardListData = membershipCardList;

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

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

                    objMemberShipCardForm.ShowDialog(this);

                    if (objMemberShipCardForm.DialogResult == DialogResult.OK)
                    {
                        FillMembershipCard(objMemberShipCardForm.membershipCardData);

                    }
                }

                //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);
            }
        }
コード例 #2
0
        private void FinishButton_Click(object sender, EventArgs e)
        {
            IMembershipCardDao membershipCardDao = new MembershipCardDao();

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

                if (isModify)
                {
                    membershipCard = txtMembershipCardName.Tag as MembershipCard;
                }
                else
                {
                    membershipCard = new MembershipCard();
                    membershipCard.creationDate = System.DateTime.Now;
                }

                membershipCard.startDate = dtpStartDate.Value;
                membershipCard.endDate = dtpEndDate.Value;

                membershipCard.name = txtMembershipCardName.Text;
                membershipCard.type = cmbType.Text;
                if (rdbActive.Checked)
                {
                    membershipCard.isActive = rdbActive.Checked;
                }
                else if (rdbInActive.Checked)
                {
                    membershipCard.isActive = false;
                }

                membershipCard.title = txtTitle.Text;
                membershipCard.code = txtCode.Text;

                if (txtPoint.Text != null && !txtPoint.Text.ToString().Equals(""))
                {
                    membershipCard.points = Convert.ToDouble(txtPoint.Text);
                }
                else
                {
                    membershipCard.points = 0;
                }

                if (txtDiscountPercentRate.Text != null && !txtDiscountPercentRate.Text.ToString().Equals(""))
                {
                    membershipCard.discountPercent = Convert.ToDouble(txtDiscountPercentRate.Text);
                }

                membershipCard.description = txtDescription.Text;

                if (isModify)
                {

                    membershipCardDao.UpdateMembershipCard(membershipCard);
                    MessageBox.Show("Membership Card " + membershipCard.id + " updated successfully");

                }
                else
                {

                    membershipCardDao.AddMembershipCard(membershipCard);
                    MessageBox.Show("Membership Card " + membershipCard.id + " created successfully");

                }

            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message);
                //Console.Write(exp.Message);
            }
        }