Пример #1
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            //数据表为空时不执行本操作
            if (bds.Current == null)
            {
                return;
            }
            Datasets.DSjckja.toptionlbRow r = (Datasets.DSjckja.toptionlbRow)(((DataRowView)bds.Current).Row);
            string cmd = "SELECT * FROM toptionxm WHERE lbdm =" + ClsQ.Q1(r.dm);

            if (ClsMSSQL.Exists(cmd, ClsDBCon.ConStrKj))
            {
                ClsMsgBox.Jg("该类别下存在项目无法删除");
                return;
            }
            ClsMsgBox.YesNo("确定要删除该记录吗?", deleting);
        }
Пример #2
0
 private void dgv_SelectionChanged(object sender, EventArgs e)
 {
     if (bds.Current == null)
     {
         lbRow = null;
         return;
     }
     lbRow = (Datasets.DSjckja.toptionlbRow)(((DataRowView)bds.Current).Row);
     //自上一次调用 AcceptChanges 之后,该行未更改。
     //该句的作用是防止在toptionlb中增加或删除记录时,
     //执行到里面的r.dm和r.mc的赋值语句时因r对应的东西为null,而报错
     if (lbRow.RowState == DataRowState.Unchanged)
     {
         toptionxmTableAdapter1.FillByLbdm(dSjckja1.toptionxm, lbRow.dm);
     }
     else
     {
         //此句是清空toptionxm表中此前装入的对应其他选项类别的选项项目
         dSjckja1.toptionxm.Clear();
     }
 }