Exemplo n.º 1
0
        private void buttonItem1_Click(object sender, EventArgs e)
        {
            int curSfid = Convert.ToInt32(grdList.SelectedRows[0].Cells["SFID"].Value);
            int curadmno = Convert.ToInt32(grdList.SelectedRows[0].Cells["AdmNo"].Value);

            Fee d = new Fee();
            DataTable dt = d.GetMaxSFID(curadmno);
            int maxsfid = Convert.ToInt32(dt.Rows[0]["maxsfid"]);



            if (grdList.SelectedRows[0].Cells["Status"].Value.ToString() == "Canceled")
            {
                MessageBox.Show("Selected Transaction is Already Canceled", "Invalid Operation", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            else if (grdList.SelectedRows[0].Cells["Status"].Value.ToString() == "Payed" || grdList.SelectedRows[0].Cells["Status"].Value.ToString() == "Not Payed")
            {
                MessageBox.Show("You Can Not Cancel Payed or UnPayed Slips", "Invalid Operation", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            else if (grdList.SelectedRows.Count == 0)
            {
                MessageBox.Show("No Record is Selected", "Select Record", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }



            else if (curSfid == maxsfid)
            {

                string di = MessageBox.Show(" Cancel Selected Transaction ?", "Cancel ?", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();

                if (di == "Yes")
                {

                    Fee f = new Fee();

                    if (f.SetCanceled(Convert.ToInt32(grdList.SelectedRows[0].Cells["SFID"].Value), Convert.ToInt32(grdList.SelectedRows[0].Cells["AdmNo"].Value), Convert.ToInt32(grdList.SelectedRows[0].Cells["Payed"].Value), Convert.ToInt32(grdList.SelectedRows[0].Cells["Total"].Value), grdList.SelectedRows[0].Cells["Status"].Value.ToString(), Convert.ToInt32(grdList.SelectedRows[0].Cells["PrevArrears"].Value)) == true)
                    {
                        MessageBox.Show("Transaction Canceled Successfully", "Status", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        if (byadmno == true && byclass == false)
                        {
                            LoadList();
                        }
                        else
                            LoadListByClass();


                    }
                    else
                    {
                        MessageBox.Show("Problem in Updating the transaction", "Status", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        if (byadmno == true && byclass == false)
                        {
                            LoadList();
                        }
                        else if (byadmno == false && byclass == true)
                            LoadListByClass();
                    }
                }

            }
            else
            {
                MessageBox.Show("You cant not Edit old Fee Records", "Invalid Operation", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }