Exemplo n.º 1
0
        private void btnCancel_Click(object sender, EventArgs e)
        {
            DialogResult Result = MessageBox.Show("Are you Sure! You Want to Cancel", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (Result == DialogResult.Yes)
            {
                usp_SEL_RenewalTableAdapter.Fill(comDataSet.usp_SEL_Renewal, txtFCardNo.Text);
                txtFCardNo.ReadOnly = false;
                DGRenewal.Show();
                btnAdd.Enabled       = true;
                btnEdit.Enabled      = true;
                btnFCardNo.Enabled   = true;
                btnReset.Enabled     = true;
                DGRenewal.Enabled    = true;
                btnAdd.Enabled       = true;
                txtReceiptNo.Enabled = true;
                btnDelete.Enabled    = true;
                btnPrint.Enabled     = true;
                this.AcceptButton    = btnAdd;
                mode = 0;
                calc = 0;
                lblRenewalYears.Text = "";
            }
        }
Exemplo n.º 2
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if (CheckFields())
            {
                bool Result = DBLayer.CHK_RWL(txtFCardNo.Text, cmbRenewalYear.Text, cmbYearTo.Text);


                try
                {
                    string   FCardNo       = txtFCardNo.Text;
                    string   Year          = cmbRenewalYear.Text;
                    DateTime Date          = Convert.ToDateTime(dpRenewalDate.Text);
                    decimal  Fee           = Convert.ToDecimal(txtRenewlFee.Text);
                    decimal  LateFee       = Convert.ToDecimal(txtLateFee.Text);
                    decimal  PoorFund      = Convert.ToDecimal(txtPoorFund.Text);
                    decimal  Total         = Convert.ToDecimal(txtTotal.Text);
                    decimal  EducationFund = Convert.ToDecimal(txtEduFund.Text);
                    decimal  KabristanFund = Convert.ToDecimal(txtKabrFund.Text);
                    decimal  ZakatFund     = Convert.ToDecimal(txtZakatFund.Text);
                    decimal  DonationFund  = Convert.ToDecimal(txtDonationFund.Text);
                    decimal  TamiratiFund  = Convert.ToDecimal(txtTamiratiFund.Text);
                    // bool Link = Convert.ToBoolean(rdbYes.Checked);
                    decimal CardFee       = Convert.ToDecimal(txtCardFee.Text);
                    string  TotalMembers  = txtTotalMembers.Text;
                    string  AdultMemebers = txtAdult.Text;
                    bool    Link          = AccountLink();
                    string  ReceiptNo     = txtReceiptNo.Text;
                    //int Account =Convert.ToInt32(cmbAccount.SelectedValue.ToString());
                    //int PoorAcc = Convert.ToInt32(cmbPoorAcc.SelectedValue.ToString());
                    string RenewalTo = cmbYearTo.Text;

                    if (mode == 1)
                    {
                        if (/*Result*/ 1 != 1)
                        {
                            MessageBox.Show("Already Renewed for range of Year!", "Duplicate", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        }
                        else
                        {
                            usp_SEL_RenewalTableAdapter.Insert1(FCardNo, Date, Year, Fee, PoorFund, LateFee, Total, Link, CardFee, AdultMemebers, TotalMembers, /*ReceiptNo*/ next().ToString("00000"), 115, 118, RenewalTo, EducationFund, KabristanFund, ZakatFund, DonationFund, TamiratiFund, new DBLayer().GetUserID());
                            tblTransactionsTableAdapter.InsertTransaction(MCKJ.frmHallBoking.HRD("Card Renewal Charges"), "RWL", Convert.ToInt32(ReceiptNo), Date, 0, Total, "Year = " + Year + " CardNo = " + FCardNo, "", "");
                            //tblTransactionsTableAdapter.InsertTransaction(115, "RWL", Convert.ToInt32(ReceiptNo), Date, Total - PoorFund, 0, "Year = " + Year + " CardNo = " + FCardNo, "", "");
                            tblTransactionsTableAdapter.InsertTransaction(117, "RWL", Convert.ToInt32(ReceiptNo), Date, PoorFund, 0, "Year = " + Year + " CardNo = " + FCardNo, "", "");
                            UpdateFamilyTable(RenewalTo);
                            MessageBox.Show("Saved Successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            usp_SEL_RenewalTableAdapter.Fill(comDataSet.usp_SEL_Renewal, FCardNo);
                            mode = 0;
                            btnReset.Show();
                            DGRenewal.Show();
                            btnAdd.Show();
                            btnEdit.Show();
                            //  btnDelete.Show();
                            btnPrint.Show();
                            btnClose.Show();
                            btnFCardNo.Show();
                            btnReset.Hide();
                            DGRenewal.Enabled   = true;
                            txtFCardNo.ReadOnly = false;
                            btnAdd.Enabled      = true;
                            btnEdit.Enabled     = true;
                            btnPrint.Enabled    = true;
                            btnDelete.Enabled   = true;
                            btnFCardNo.Enabled  = true;
                        }
                    }
                    else if (mode == 0)
                    {
                        int[] idz = TransactionID(Convert.ToInt32(ReceiptNo));
                        if (RDate == cmbRenewalYear.Text && ToYr == cmbYearTo.Text)
                        {
                            usp_SEL_RenewalTableAdapter.Update1(ID, FCardNo, Date, Year, Fee, PoorFund, LateFee, Total, Link, CardFee, AdultMemebers, TotalMembers, ReceiptNo, 115, 118, RenewalTo, EducationFund, KabristanFund, ZakatFund, DonationFund, TamiratiFund, new DBLayer().GetUserID());

                            tblTransactionsTableAdapter.UpdateTransaction(MCKJ.frmHallBoking.HRD("Card Renewal Charges"), "RWL", Convert.ToInt32(ReceiptNo), Date, 0, Total, "Year = " + Year + " CardNo = " + FCardNo, "", "", idz[0]);
                            tblTransactionsTableAdapter.UpdateTransaction(115, "RWL", Convert.ToInt32(ReceiptNo), Date, Total - PoorFund, 0, "Year = " + Year + " CardNo = " + FCardNo, "", "", idz[1]);
                            tblTransactionsTableAdapter.UpdateTransaction(118, "RWL", Convert.ToInt32(ReceiptNo), Date, PoorFund, 0, "Year = " + Year + " CardNo = " + FCardNo, "", "", idz[2]);

                            UpdateFamilyTable(RenewalTo);
                            MessageBox.Show("Updated Successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            usp_SEL_RenewalTableAdapter.Fill(comDataSet.usp_SEL_Renewal, FCardNo);
                            btnReset.Show();
                            DGRenewal.Show();
                            btnAdd.Show();
                            btnEdit.Show();
                            //  btnDelete.Show();
                            btnPrint.Show();
                            btnClose.Show();
                            btnFCardNo.Show();
                            btnReset.Hide();
                            DGRenewal.Enabled    = true;
                            txtFCardNo.ReadOnly  = false;
                            txtReceiptNo.Enabled = true;
                            btnAdd.Enabled       = true;
                            btnEdit.Enabled      = true;
                            btnPrint.Enabled     = true;
                            btnDelete.Enabled    = true;
                            btnFCardNo.Enabled   = true;
                        }
                        else
                        {
                            if (Result)
                            {
                                MessageBox.Show("Already Renewed for range of Year!", "Duplicate", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else
                            {
                                usp_SEL_RenewalTableAdapter.Update1(ID, FCardNo, Date, Year, Fee, PoorFund, LateFee, Total, Link, CardFee, AdultMemebers, TotalMembers, ReceiptNo, 115, 118, RenewalTo, EducationFund, KabristanFund, ZakatFund, DonationFund, TamiratiFund, new DBLayer().GetUserID());
                                tblTransactionsTableAdapter.UpdateTransaction(MCKJ.frmHallBoking.HRD("Card Renewal Charges"), "RWL", Convert.ToInt32(ReceiptNo), Date, 0, Total, "Year = " + Year + " CardNo = " + FCardNo, "", "", idz[0]);
                                tblTransactionsTableAdapter.UpdateTransaction(115, "RWL", Convert.ToInt32(ReceiptNo), Date, Total - PoorFund, 0, "Year = " + Year + " CardNo = " + FCardNo, "", "", idz[1]);
                                tblTransactionsTableAdapter.UpdateTransaction(118, "RWL", Convert.ToInt32(ReceiptNo), Date, PoorFund, 0, "Year = " + Year + " CardNo = " + FCardNo, "", "", idz[2]);
                                MessageBox.Show("Updated Successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                usp_SEL_RenewalTableAdapter.Fill(comDataSet.usp_SEL_Renewal, FCardNo);
                                btnReset.Show();
                                DGRenewal.Show();
                                btnAdd.Show();
                                btnEdit.Show();
                                //  btnDelete.Show();
                                btnPrint.Show();
                                btnClose.Show();
                                btnFCardNo.Show();
                                btnReset.Hide();
                                DGRenewal.Enabled    = true;
                                txtFCardNo.ReadOnly  = false;
                                txtReceiptNo.Enabled = true;
                                btnAdd.Enabled       = true;
                                btnEdit.Enabled      = true;
                                btnPrint.Enabled     = true;
                                btnDelete.Enabled    = true;
                                btnFCardNo.Enabled   = true;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                txtFCardNo.Focus();
                this.AcceptButton = btnAdd;
                calc = 0;
                lblRenewalYears.Text = "";
            }
        }