示例#1
0
        private void findMember(MemberInfo memInfo)
        {
            setMemberFields(memInfo);

            using (MonthlyPayment pay = new MonthlyPayment(true))
            {
                pay.MemberID = memInfo.ID;
                SetHistryGrid(pay.GetPaymentHistry());
            }

            amountText.Focus();
            amountText.Select(0, 5);
        }
示例#2
0
        private void addbtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidateBeforeAdd())
                {
                    if (paymentID == 0 && monthlyAmount > 0)
                    {
                        int numberofMonths = (int)amountText.Value / monthlyAmount;
                        for (int i = 0; i < numberofMonths; i++)
                        {
                            using (MonthlyPayment pay = new MonthlyPayment(true))
                            {
                                setObjectFromFieldValues(pay, i);

                                if (pay.MemberID > 0 && pay.Add() == 1)
                                {
                                    // MessageView.ShowMsg("Sucessfully Added");

                                    //errorProvider1.SetError(idTxt, string.Empty);
                                    //errorProvider1.SetError(nameTxt, string.Empty);
                                    statusText.Visible   = true;
                                    timer1.Enabled       = true;
                                    extraAmountNum.Value = 0;
                                }
                            }
                        }

                        clear(1);
                    }
                    else if (memberID > 0)
                    {
                        using (MonthlyPayment pay = new MonthlyPayment(true))
                        {
                            pay.ID = paymentID;
                            setObjectFromFieldValues(pay, 0);

                            if (MessageView.ShowQuestionMsg("Update record") == DialogResult.OK)
                            {
                                if (pay.Update() == 1)
                                {
                                    SetHistryGrid(pay.GetPaymentHistry());

                                    extraAmountNum.Value = 0;
                                }
                            }
                        }
                    }
                }
            }
            //  catch()
            catch (Exception ex)
            {
                if (ex.Message.StartsWith("Duplicate entry"))
                {
                    MessageView.ShowErrorMsg("Already Added");
                }
                else
                {
                    MessageView.ShowErrorMsg(ex.Message);
                }
            }
        }