Esempio n. 1
0
 /// <summary>
 /// 光盘页单元格点击事件
 /// </summary>
 private void Dgv_GPDJ_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex != -1 && e.ColumnIndex != -1)
     {
         object trcId = dgv_GPDJ.Rows[e.RowIndex].Cells["trc_id"].Value;
         if (trcId != null)
         {
             if ("control".Equals(dgv_GPDJ.Columns[e.ColumnIndex].Name))
             {
                 int state = Convert.ToInt32(dgv_GPDJ.Rows[e.RowIndex].Cells["trc_status"].Tag);
                 if (state == 2)
                 {
                     string msg = "此光盘已读取,重新读取会覆盖旧数据。\r\n是否确认继续?";
                     if (XtraMessageBox.Show(msg, "确认提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                     {
                         SqlHelper.ExecuteNonQuery($"DELETE FROM backup_files_info WHERE bfi_trcid='{trcId}'");
                     }
                     else
                     {
                         return;
                     }
                 }
                 object     trpName = dgv_GPDJ.Rows[e.RowIndex].Tag;
                 Frm_CDRead read    = new Frm_CDRead(trcId, trpName);
                 if (read.ShowDialog() == DialogResult.OK)
                 {
                     //更新光盘信息
                     string updateSql = $"UPDATE transfer_registraion_cd SET trc_status='{(int)ReadStatus.ReadSuccess}' WHERE trc_id='{trcId}'";
                     SqlHelper.ExecuteNonQuery(updateSql);
                     LoadGPDJ(null);
                 }
             }
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 单元格点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Dgv_SWDJ_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex != -1 && e.ColumnIndex != -1)
            {
                //当前点击单元格的值
                object value = dgv_SWDJ.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
                string name  = dgv_SWDJ.Columns[e.ColumnIndex].Name;
                //光盘数-点击事件
                if ("trp_cd_amount".Equals(name))
                {
                    if (Convert.ToInt32(value) != 0)
                    {
                        object trpId   = dgv_SWDJ.Rows[e.RowIndex].Cells["trp_id"].Value;
                        object trpName = dgv_SWDJ.Rows[e.RowIndex].Cells["trp_name"].Value;
                        LoadCDDataScoure(trpId, trpName);
                    }
                }
                //添加光盘-点击事件
                else if ("addpc".Equals(name))
                {
                    object    currentRowId = dgv_SWDJ.Rows[e.RowIndex].Cells["trp_id"].Value;
                    Frm_AddCD frm          = new Frm_AddCD(currentRowId.ToString());
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        if (currentUnit != null)
                        {
                            StringBuilder querySql = new StringBuilder("SELECT ");
                            querySql.Append("pc.trp_id, dd_name, trp_name, trp_code, trp_submit_status, trp_cd_amount");
                            querySql.Append(" FROM transfer_registration_pc pc,data_dictionary cs");
                            querySql.Append(" WHERE pc.com_id = cs.dd_id AND trp_submit_status=1");
                            querySql.Append(" AND com_id='" + currentUnit + "'");
                            LoadPCDataScoure(querySql.ToString());
                            dgv_SWDJ.Tag = SqlHelper.ExecuteOnlyOneQuery($"SELECT cs_code FROM data_dictionary WHERE dd_id ='{currentUnit}'");
                        }
                        else
                        {
                            LoadPCDataScoure(null);
                        }
                    }
                }
                //提交 - 点击事件
                else if ("submit".Equals(name))
                {
                    object currentRowId = dgv_SWDJ.Rows[e.RowIndex].Cells["trp_id"].Value;
                    if (currentRowId != null && !"已提交".Equals(dgv_SWDJ.Rows[e.RowIndex].Cells[e.ColumnIndex].Value))
                    {
                        //如果当前批次下存在光盘且未读取,或者存在读取失败的记录,则不允许提交
                        string querySql  = $"SELECT COUNT(trc_id) FROM transfer_registraion_cd WHERE trp_id='{currentRowId}' AND trc_status<>{(int)ReadStatus.ReadSuccess}";
                        int    logAmount = SqlHelper.ExecuteCountQuery(querySql);
                        if (logAmount == 0)
                        {
                            if (XtraMessageBox.Show("确定要提交当前选中项吗?", "确认提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                            {
                                string updateSql = $"UPDATE transfer_registration_pc SET trp_submit_status={(int)ObjectSubmitStatus.SubmitSuccess} WHERE trp_id='{currentRowId}'";
                                SqlHelper.ExecuteNonQuery(updateSql);

                                XtraMessageBox.Show("提交成功。");
                                dgv_SWDJ.Rows.RemoveAt(e.RowIndex);
                            }
                        }
                        else
                        {
                            XtraMessageBox.Show("当前批次下存在尚未处理的光盘。", "提交失败", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        }
                    }
                }
                //光盘读写事件
                else if ("trc_read".Equals(name))
                {
                    object trcId = dgv_SWDJ.Rows[e.RowIndex].Cells["trc_id"].Value;
                    int    count = SqlHelper.ExecuteCountQuery($"SELECT COUNT(bfi_id) FROM backup_files_info WHERE bfi_trcid='{trcId}'");
                    if (count > 0)
                    {
                        if (XtraMessageBox.Show("此光盘已读取,重复读取会删除旧数据,是否继续?", "确认提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK)
                        {
                            SqlHelper.ExecuteNonQuery($"DELETE FROM backup_files_info WHERE bfi_trcid='{trcId}'");
                        }
                        else
                        {
                            return;
                        }
                    }
                    object     trpName = dgv_SWDJ.Rows[e.RowIndex].Cells["trc_read"].Tag;
                    Frm_CDRead read    = new Frm_CDRead(trcId, trpName);
                    if (read.ShowDialog() == DialogResult.OK)
                    {
                        StringBuilder sb = new StringBuilder();
                        //更新光盘信息
                        //如果当前光盘所属批次已提交且光盘是首次被读取,则证明是批次后补录光盘,则已录批次下所有项目课题均关联此光盘ID
                        int pstate = (int)SqlHelper.ExecuteOnlyOneQuery($"SELECT trp_submit_status FROM transfer_registration_pc WHERE trp_id=" +
                                                                        $"(SELECT trp_id FROM transfer_registraion_cd WHERE trc_id='{trcId}');");
                        int cstate = (int)SqlHelper.ExecuteOnlyOneQuery($"SELECT trc_status FROM transfer_registraion_cd WHERE trc_id='{trcId}';");
                        if (pstate == 2 && cstate == 1)
                        {
                            /*-- 批次下的重大专项 - 项目/课题 --*/
                            object trpId = dgv_SWDJ.Rows[e.RowIndex].Tag;
                            object impId = SqlHelper.ExecuteOnlyOneQuery($"SELECT imp_id FROM imp_dev_info WHERE imp_obj_id=(SELECT imp_id FROM imp_info WHERE imp_obj_id = '{trpId}');");
                            if (impId != null)
                            {
                                UpdateTrcId(impId, trcId, ref sb);
                            }

                            /*-- 批次下的计划 - 项目/课题 --*/
                            object piId = SqlHelper.ExecuteOnlyOneQuery($"SELECT pi_id FROM project_info WHERE pi_categor=1 AND pi_obj_id='{trpId}'");
                            if (piId != null)
                            {
                                UpdateTrcId(piId, trcId, ref sb);
                            }
                        }
                        sb.Append($"UPDATE transfer_registraion_cd SET trc_status='{(int)ReadStatus.ReadSuccess}' WHERE trc_id='{trcId}';");
                        SqlHelper.ExecuteNonQuery(sb.ToString());
                        XtraMessageBox.Show("读写成功。");
                    }
                }
            }
        }