Пример #1
0
        private void btnDeleteIPP_Click(object sender, System.EventArgs e)
        {
            IPPs = new IPP();
            DataTable dt;
            ACMS.XtraUtils.GridViewUtils.UpdateData(IPPGridView);
            DataRow row = IPPGridView.GetDataRow(IPPGridView.FocusedRowHandle);
            if (row != null)
            {
                string strSQL="select * from tblReceiptPayment where nIPPId = " + Convert.ToInt32(row["nIPPId"]);
                DataSet _ds = new DataSet();

                SqlHelper.FillDataset(connection,CommandType.StoredProcedure,"UP_GETDATA",_ds,new string[] {"table"}, new SqlParameter("@strSQL", strSQL) );
                dt = _ds.Tables["table"];

                if (dt.Rows.Count > 0)
                {
                    MessageBox.Show(this, "Cannot be deleted. Please unlink all the receipt from the IPP.");
                    return;
                }

                DialogResult result = MessageBox.Show(this, "Do you really want to delete record with IPP ID = " + row["NIPPID"].ToString() + "?",
                    "Delete?", MessageBoxButtons.YesNo);

                if (result == DialogResult.Yes)
                {
                    if (IPPs.Delete(ACMS.Convert.ToInt32(row["NIPPID"])))
                    {
                        MessageBox.Show(this, "Record deleted");
                    }
                }
            }
            LoadIPP();
        }