コード例 #1
0
        private void btnDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //if (BsfGlobal.FindPermission("CallType Master-Delete") == false)
            //{
            //    MessageBox.Show("You don't have Rights to Area Master-Delete");
            //    return;
            //}

            int  iCallTypeId = Convert.ToInt32(CommFun.IsNullCheck(DGvTransView.GetFocusedRowCellValue("CallTypeId"), CommFun.datatypes.vartypenumeric));
            bool bAns = false; bool bAns1 = false;

            bAns  = CallSheetEntryBL.CallTypeMasterFound(iCallTypeId);
            bAns1 = CallSheetEntryBL.CallTypeSysFound(iCallTypeId);
            if (bAns == true)
            {
                MessageBox.Show("Do not Delete, CallType Already Used"); return;
            }
            if (bAns1 == true)
            {
                MessageBox.Show("Do not Delete, Default CallType"); return;
            }

            DialogResult result1 = MessageBox.Show("Are you sure", "CallType Master Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result1 == DialogResult.Yes)
            {
                CallSheetEntryBL.DeleteCallTypeMaster(iCallTypeId);
                DGvTransView.DeleteSelectedRows();
            }
        }
コード例 #2
0
        private void btnDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string sSql;

            if (BsfGlobal.FindPermission("OC Master-Delete") == false)
            {
                MessageBox.Show("You don't have Rights to OC Template-Delete");
                return;
            }
            if (Convert.ToBoolean(CommFun.IsNullCheck(DGvTransView.GetFocusedRowCellValue("SysDefault"), CommFun.datatypes.vartypenumeric)) == true)
            {
                MessageBox.Show("Do not Delete,Default OtherCost"); return;
            }
            else
            {
                int  iOCId = Convert.ToInt32(CommFun.IsNullCheck(DGvTransView.GetFocusedRowCellValue("OtherCostId"), CommFun.datatypes.vartypenumeric));
                bool bAns  = false;
                sSql = " Select OtherCostId From CCOtherCost Where OtherCostId= " + iOCId + " " +
                       " Union All " +
                       " Select OtherCostId From FlatTypeOtherCost Where OtherCostId= " + iOCId + " " +
                       " Union All " +
                       " Select OtherCostId From FlatOtherCost Where OtherCostId = " + iOCId + " " +
                       " Union All " +
                       " Select OtherCostId From PaymentSchedule Where OtherCostId = " + iOCId + " AND SchType IN('O') " +
                       " Union All " +
                       " Select OtherCostId From PaymentScheduleFlat Where OtherCostId = " + iOCId + " AND SchType IN('O') " +
                       " Union All " +
                       " Select StageId From StageDetails Where StageId = " + iOCId + " AND SchType IN('O') " +
                       " Union All " +
                       " Select StageId From ProgressBillRegister Where StageId = " + iOCId + " AND SchType IN('O') ";
                DataTable      dt  = new DataTable();
                SqlDataAdapter sda = new SqlDataAdapter(sSql, BsfGlobal.OpenCRMDB());
                sda.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    bAns = true;
                }
                dt.Dispose();
                sda.Dispose();
                BsfGlobal.g_CRMDB.Close();
                if (bAns == true)
                {
                    MessageBox.Show("Do not Delete, OtherCost Already Used"); return;
                }

                DialogResult result1 = MessageBox.Show("Are you sure", "OtherCost Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result1 == DialogResult.Yes)
                {
                    sSql = String.Format("DELETE FROM OtherCostMaster WHERE OtherCostId={0}", iOCId);
                    using (SqlCommand cmd = new SqlCommand(sSql, BsfGlobal.OpenCRMDB()))
                    {
                        cmd.ExecuteNonQuery();
                        DGvTransView.DeleteSelectedRows();
                    }
                }
            }
        }