示例#1
0
 /// <summary>
 /// 删除或恢复旧文件
 /// </summary>
 /// <param name="planInfo"></param>
 /// <param name="operType"></param>
 private static void DeleteOrResumeOldFile(CADS.Model.PlanManageInfoList planInfo, string operType)
 {
     try
     {
         string basePath           = AppDomain.CurrentDomain.BaseDirectory;
         string planDirectory      = Path.Combine(basePath, "预案模板");
         string destFileName       = Path.Combine(planDirectory, planInfo.Path);
         string fileNameWithoutExt = Path.GetFileNameWithoutExtension(destFileName);
         string oldFileNameBak     = Path.Combine(planDirectory, fileNameWithoutExt + ".bak");
         if (operType == "resume")
         {
             if (File.Exists(destFileName))
             {
                 File.Delete(destFileName);
             }
             if (File.Exists(oldFileNameBak))
             {
                 File.Move(oldFileNameBak, destFileName);
             }
         }
         else if (operType == "delete")
         {
             if (File.Exists(oldFileNameBak))
             {
                 File.Delete(oldFileNameBak);
             }
         }
     }
     catch
     {
     }
 }
示例#2
0
 /// <summary>
 /// 数据操作
 /// </summary>
 /// <param name="Mess">区别编辑还是新增还是删除</param>
 private bool OpreationDB(string Mess, CADS.Model.PlanManageInfoList planInfo)
 {
     try
     {
         string Error  = "";
         bool   Result = false;
         if (Mess == "添加")
         {
             Result = plan.Add(planInfo);
         }
         if (Mess == "编辑")
         {
             Result = plan.Update(planInfo);
         }
         if (Mess == "删除")
         {
             Result = plan.Delete(planInfo.PlanID);
         }
         if (Result == true)
         {
             MessageBox.Show("预案信息" + Mess + "成功");
             return(true);
         }
         else
         {
             MessageBox.Show("预案信息" + Mess + "失败,请稍后再试!");
             return(false);
         }
     }
     catch (Exception e)
     {
         MessageBox.Show("预案信息" + Mess + "失败:" + e.Message);
         return(false);
     }
 }
示例#3
0
        private void btn_DutyEdit_Click(object sender, EventArgs e)
        {
            if (dgvPlanInfos.SelectedRows.Count < 1)
            {
                MessageBox.Show("请选中一行数据!");
                return;
            }
            CADS.Model.PlanManageInfoList planInfo = new CADS.Model.PlanManageInfoList();
            planInfo.ID          = Convert.ToInt32(dgvPlanInfos.CurrentRow.Cells[0].Value);
            planInfo.PlanID      = dgvPlanInfos.CurrentRow.Cells[1].Value.ToString();
            planInfo.PlanTitle   = dgvPlanInfos.CurrentRow.Cells[2].Value.ToString();
            planInfo.Description = dgvPlanInfos.CurrentRow.Cells[3].Value.ToString();
            planInfo.Path        = dgvPlanInfos.CurrentRow.Cells[4].Value.ToString();
            Form_PlanAdd addOrEdit = new Form_PlanAdd("edit", planInfo);

            addOrEdit.ShowDialog();
            if (addOrEdit.DialogResult == DialogResult.OK)
            {
                OpreationDB("编辑", addOrEdit.planInfo);
                RefreshDataGridView();
            }
        }
示例#4
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (dgvPlanInfos.SelectedRows.Count < 1)
     {
         MessageBox.Show("请选中一行数据!");
         return;
     }
     if (MessageBox.Show("确定要删除该行数据?", null, MessageBoxButtons.YesNo) != DialogResult.Yes)
     {
         return;
     }
     CADS.Model.PlanManageInfoList planInfo = new CADS.Model.PlanManageInfoList();
     planInfo.ID          = Convert.ToInt32(dgvPlanInfos.CurrentRow.Cells[0].Value);
     planInfo.PlanID      = dgvPlanInfos.CurrentRow.Cells[1].Value.ToString();
     planInfo.PlanTitle   = dgvPlanInfos.CurrentRow.Cells[2].Value.ToString();
     planInfo.Description = dgvPlanInfos.CurrentRow.Cells[3].Value.ToString();
     planInfo.Path        = dgvPlanInfos.CurrentRow.Cells[4].Value.ToString();
     planInfo.Mark        = dgvPlanInfos.CurrentRow.Cells[5].Value.ToString();
     if (OpreationDB("删除", planInfo))
     {
         string basePath      = AppDomain.CurrentDomain.BaseDirectory;
         string planDirectory = Path.Combine(basePath, "预案模板");
         string destFileName  = Path.Combine(planDirectory, planInfo.Path);
         try
         {
             File.Delete(destFileName);
         }
         catch (Exception ex)
         {
             //MessageBox.Show(ex.Message);
         }
         finally
         {
             RefreshDataGridView();
         }
     }
 }
示例#5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(CADS.Model.PlanManageInfoList model)
 {
     return(dal.Update(model));
 }
示例#6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(CADS.Model.PlanManageInfoList model)
 {
     return(dal.Add(model));
 }