コード例 #1
0
        private void DelSHBItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show(@"确定要删除?", @"确定?", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                {
                    return;
                }
                try
                {
                    // 获取被删除计量表的FID
                    var tfid   = (long)contextMenuStrip2.Tag;
                    var isLock = DBEntityFinder.Instance.VerifyLTTID(detail_fid);
                    if (!isLock)
                    {
                        PublicMethod.Instance.AlertDialog("该设备没有被工单锁定,不能删除!");
                        return;
                    }

                    //var temshb =
                    //    DBManager.Instance.GetEntities<Gg_jx_shbd_pt>(
                    //        o => o.G3E_FID == tfid && o.EntityState != EntityState.Delete).FirstOrDefault();
                    //if (temshb != null && (temshb.LTT_ID != null && (DBEntityFinder.Instance.VerifyLTTID((decimal)temshb.LTT_ID) == false)))
                    //{
                    //    PublicMethod.Instance.AlertDialog("该设备没有被工单锁定,不能删除!");
                    //    return;
                    //}
                    SHBDeleteManager.DeleteSGB(tfid, new List <DBEntity>());
                    //删除一个户表控件,刷新界面
                    var t1 = Controls;
                    foreach (var t2 in Controls)
                    {
                        var t3 = t2 as Dyhb;
                        if (t3 != null && t3.DyhbFid == tfid)
                        {
                            pbs.Remove(t3);
                            Controls.Remove(t3);
                        }
                    }
                }
                catch (Exception ex)
                {
                    PublicMethod.Instance.AlertDialog(String.Format("删除过程中出现错误:{0}", ex.Message));
                }
            }
            catch (Exception ex)
            {
                PublicMethod.Instance.AlertDialog(ex.Message);
            }
        }
コード例 #2
0
 /// <summary>
 /// 批量删除
 /// </summary>
 /// <param name="fid"></param>
 /// <param name="backupDBEntity"> </param>
 /// <returns></returns>
 public static List <DBEntity> BatchDeleteFromSHB(long fid, List <DBEntity> backupDBEntity)
 {
     try
     {
         //获取所有计量表
         var t = DBManager.Instance.GetEntity <Detailreference_n>(fid);
         if (t != null)
         {
             var ents = GetSHB_PT(t.G3E_DETAILID);
             if (ents != null)
             {
                 foreach (long tmp in ents)
                 {
                     backupDBEntity = SHBDeleteManager.DeleteSGB(tmp, backupDBEntity);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         LogManager.Instance.Error(ex);
     }
     return(backupDBEntity);
 }