Exemplo n.º 1
0
        private void btnDisAddTemp_Click(object sender, EventArgs e)
        {
            //保存中间列表数据到不显示列表数据
            ProxyBllTEST_INFO       bllTest_Info       = new ProxyBllTEST_INFO();
            ProxyBllTEST_ALLOCATION bllTest_Allocation = new ProxyBllTEST_ALLOCATION();

            DataSet dsTestInfo;

            string now_taskid = "";

            if (lstTasklist.SelectedItems.Count == 0)
            {
                MessageBox.Show("请选择需要继续进行爬高试验的试验编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                try
                {
                    //修改选中任务编号的试验状态
                    now_taskid = lstTasklist.SelectedItems[0].ToString();
                    bllTest_Info.update_status(now_taskid);
                    bllTest_Allocation.update_status(now_taskid);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("任务编号:" + now_taskid + "的试验基础信息修改保存错误!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                MessageBox.Show("爬高试验状态修改完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                BindGridview();
            }
        }
Exemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!now_taskId.Trim().Equals(""))
            {
                //试验样品信息各数据行的数据有效,保存该组数据到T_TEST_SAMPLE_INFO表中
                ProxyBllTEST_ALLOCATION bllTestAllocation = new ProxyBllTEST_ALLOCATION();

                //删除该任务编号的样品分配信息数据
                string dropWhere = "";
                dropWhere = " F_TEST_TASK_ID='" + now_taskId + "' ";
                bllTestAllocation.DropWhere(dropWhere);

                //生成任务编号now_taskId的样品编号信息,并写入T_TEST_ALLOCATION
                for (int i = 0; i < _TestSampleTable.Rows.Count; i++)
                {
                    var modelTestAllocation = new ModelTEST_ALLOCATION();

                    modelTestAllocation.F_TEST_TASK_ID    = now_taskId;
                    modelTestAllocation.F_TEST_SAMPLE_ID  = _TestSampleTable.Rows[i]["F_TEST_SAMPLE_ID"].ToString();
                    modelTestAllocation.F_LOAD_ID         = _TestSampleTable.Rows[i]["F_LOAD_ID"].ToString();
                    modelTestAllocation.F_LOAD_CHANNEL_ID = _TestSampleTable.Rows[i]["F_LOAD_CHANNEL_ID"].ToString();
                    modelTestAllocation.F_SAMPLE_STATUS   = 0;
                    modelTestAllocation.F_CREATE_TIME     = DateTime.Now;
                    modelTestAllocation.F_OPERATOR_ID     = AppGlobal.GUserId;
                    modelTestAllocation.F_OPERATIONTIME   = DateTime.Now;
                    modelTestAllocation.F_DEL             = 0;
                    bllTestAllocation.Add_KHD(modelTestAllocation);
                }

                //试验参数数据填写值有效,保存
                ProxyBllTEST_PAR_VALUE_SWJ bllTestParValue = new ProxyBllTEST_PAR_VALUE_SWJ();
                //删除该任务编号的试验开始命令参数值
                bllTestParValue.DropByTaskId(now_taskId);

                for (int i = 0; i < _TestCommStartPar.Rows.Count; i++)
                {
                    var ModelTEST_PAR_VALUE_SWJ = new ModelTEST_PAR_VALUE_SWJ();
                    ModelTEST_PAR_VALUE_SWJ.F_TASK_ID = now_taskId;
                    //程序代码:在客户端表中备用,均填写为000
                    ModelTEST_PAR_VALUE_SWJ.F_PROGRAM_CODE  = txtProgram.Text;
                    ModelTEST_PAR_VALUE_SWJ.F_WORKTYPE_CODE = txtWorkType.Text;
                    ModelTEST_PAR_VALUE_SWJ.F_SENDPAR_NAME  = _TestCommStartPar.Rows[i]["F_SENDPAR_NAME"].ToString();
                    ModelTEST_PAR_VALUE_SWJ.F_SENDPAR_VALUE = _TestCommStartPar.Rows[i]["F_SENDPAR_VALUE"].ToString();
                    //ModelTEST_PAR_VALUE_KHD.F_SENDPAR_UNIT = _TestCommStartPar.Rows[i]["F_PAR_UNIT"].ToString();
                    ModelTEST_PAR_VALUE_SWJ.F_SENDORDER     = Convert.ToInt16(_TestCommStartPar.Rows[i]["colSENDORDER"].ToString());
                    ModelTEST_PAR_VALUE_SWJ.F_CREATE_TIME   = DateTime.Now;
                    ModelTEST_PAR_VALUE_SWJ.F_OPERATOR_ID   = AppGlobal.GUserId;
                    ModelTEST_PAR_VALUE_SWJ.F_OPERATIONTIME = DateTime.Now;
                    ModelTEST_PAR_VALUE_SWJ.F_DEL           = 0;

                    bllTestParValue.Add(ModelTEST_PAR_VALUE_SWJ);
                }
                MessageBox.Show("任务编号:" + now_taskId + "的上位机模拟数据保存完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 根据任务编号显示试验任务样品信息的内容
        /// </summary>
        /// <param name="taskId">任务编号</param>
        private void displayTaskSampleInfoByTaskId(string taskId)
        {
            RemoveALLRow(_TestSampleTable);
            //读取选定试验任务的试验样品数据
            ProxyBllTEST_ALLOCATION bllTestSampleAlloction = new ProxyBllTEST_ALLOCATION();

            _TestSampleTable = bllTestSampleAlloction.GetAndDisplaySampleInfo(_TestSampleTable, taskId);

            if (_TestSampleTable.Rows.Count == 0)
            {
                _TestSampleTable.Rows.Add();
            }
            gcSampleInfoList.DataSource = _TestSampleTable;
        }
Exemplo n.º 4
0
        /// <summary>
        /// 保存任务按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            int saveflag = 0;

            string now_taskId = "";

            now_taskId = txtTaskId.Text;

            if (!now_taskId.Trim().Equals(""))
            {
                //2015年10月18日修改,增加保存试验任务时判断该任务编号是否存在已运行的样品(t_test_allocation表trunc(f_sample_status/10)>1)
                //如果存在,不可进行保存操作
                ProxyBllTEST_ALLOCATION bllTestAllocation = new ProxyBllTEST_ALLOCATION();
                DataSet dsTestSample = bllTestAllocation.GetList(" trunc(F_SAMPLE_STATUS/10)>1 AND F_TEST_TASK_ID='" + now_taskId + "' ");
                if (dsTestSample != null && dsTestSample.Tables[0].Rows.Count != 0)
                {
                    MessageBox.Show("任务编号:" + now_taskId + "的试验任务中存在已运行的样品,不可进行保存操作!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                //判断该试验任务编号的信息是否处于“已提交”状态
                //如果当前保存任务为“已提交”状态任务,执行保存操作后,提示任务状态将修改为“未提交”状态。需要重新执行提交操作。
                ProxyBllTESINFODB bllTestDB = new ProxyBllTESINFODB();
                DataSet           dsTaskId  = bllTestDB.GetList(" F_TEST_TASK_ID='" + now_taskId + "' ");
                if (dsTaskId != null && dsTaskId.Tables[0].Rows.Count != 0)
                {
                    DialogResult dialogResult = XtraMessageBox.Show("任务编号:" + now_taskId + "的试验任务已提交,是否重新保存任务信息?", "选择", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (dialogResult == DialogResult.No)
                    {
                        return;
                    }
                    else
                    {
                        bllTestDB.DropWhere(" F_TEST_TASK_ID='" + now_taskId + "' ");
                    }
                }
                //判断试验基础信息必填项是否已填写
                //试验基础信息必填项已填写,保存该组数据到T_TEST_INFO表中
                if (judgeTestBaseInfo())
                {
                    BllTEST_INFO blltest_info = new BllTEST_INFO();

                    //判断该任务编号在数据库中是否存在,如果存在进行修改处理,否则进行新增操作
                    DataSet dsTaskCount   = blltest_info.GetTaskCount(now_taskId);
                    int     temptaskCount = -1;

                    if (dsTaskCount != null)
                    {
                        if (dsTaskCount.Tables[0].Rows.Count > 0)
                        {
                            temptaskCount = Convert.ToInt16(dsTaskCount.Tables[0].Rows[0][0].ToString());
                        }
                    }
                    if (temptaskCount == 0)  //新增操作
                    {
                        try
                        {
                            //将试验任务数据写入Model类中
                            CreateOrUpdateTestInfo(1);
                            blltest_info.Add(_mdlTestInfo);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("任务编号:" + now_taskId + "的试验基础信息新增保存错误!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }
                    else  //修改操作
                    {
                        try
                        {
                            //将试验任务数据写入Model类中
                            CreateOrUpdateTestInfo(2);
                            blltest_info.Update(_mdlTestInfo);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("任务编号:" + now_taskId + "的试验基础信息修改保存错误!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }
                    saveflag = saveflag + 1;
                }

                //2015年10月18日修改--判断该任务是否可修改样品,如果可以,执行保存,如不可以,不需执行保存样品的操作
                if (gcSampleInfoList.Enabled)
                {
                    //判断试验样品信息是否有数据行,各数据行的数据是否有效
                    if (judgeTestSampleInfo())
                    {
                        //试验样品信息各数据行的数据有效,保存该组数据到T_TEST_SAMPLE_INFO表中
                        ProxyBllTEST_SAMPLE_INFO bllTestSampleInfo = new ProxyBllTEST_SAMPLE_INFO();

                        //删除该任务编号的样品数据
                        bllTestSampleInfo.DropByTaskId(now_taskId);

                        for (int i = 0; i < _TestSampleTable.Rows.Count; i++)
                        {
                            var modelTestSampleInfo = new ModelTEST_SAMPLE_INFO();
                            modelTestSampleInfo.F_TEST_TASK_ID     = now_taskId;
                            modelTestSampleInfo.F_SAMPLE_NUM       = Convert.ToInt16(_TestSampleTable.Rows[i]["F_SAMPLE_NUM"].ToString());
                            modelTestSampleInfo.F_SAMPLE_GROUP_NUM = _TestSampleTable.Rows[i]["F_SAMPLE_GROUP_NUM"].ToString();
                            modelTestSampleInfo.F_SAMPLE_MEMO      = _TestSampleTable.Rows[i]["F_SAMPLE_MEMO"].ToString();
                            modelTestSampleInfo.F_CREATE_TIME      = DateTime.Now;
                            modelTestSampleInfo.F_OPERATOR_ID      = AppGlobal.GUserId;
                            modelTestSampleInfo.F_OPERATIONTIME    = DateTime.Now;
                            modelTestSampleInfo.F_DEL = 0;

                            bllTestSampleInfo.Add(modelTestSampleInfo);
                        }

                        //生成样品编号,并写入T_TEST_ALLOCATION表中,写入任务编号F_TEST_TASK_ID、样品编号F_TEST_SAMPLE_ID字段
                        //运行状态F_SAMPLE_STATUS值为-1,状态为未分配

                        //删除该任务编号的样品分配信息数据
                        string dropWhere = "";
                        dropWhere = " F_TEST_TASK_ID='" + now_taskId + "' ";
                        bllTestAllocation.DropWhere(dropWhere);

                        //生成任务编号now_taskId的样品编号信息,并写入T_TEST_ALLOCATION
                        for (int i = 0; i < _TestSampleTable.Rows.Count; i++)
                        {
                            var modelTestAllocation = new ModelTEST_ALLOCATION();

                            int    temp_sample_num = Convert.ToInt16(_TestSampleTable.Rows[i]["F_SAMPLE_NUM"].ToString());
                            string temp_group_num  = _TestSampleTable.Rows[i]["F_SAMPLE_GROUP_NUM"].ToString();
                            for (int k = 1; k <= temp_sample_num; k++)
                            {
                                modelTestAllocation.F_TEST_TASK_ID = now_taskId;

                                //以%2f的形式显示
                                if (k < 10)
                                {
                                    modelTestAllocation.F_TEST_SAMPLE_ID = temp_group_num + "-0" + k.ToString();
                                }
                                else
                                {
                                    modelTestAllocation.F_TEST_SAMPLE_ID = temp_group_num + "-" + k.ToString();
                                }
                                //样品编码,试验样品待分配试验通道,状态值为11
                                modelTestAllocation.F_SAMPLE_STATUS = 11;
                                modelTestAllocation.F_CREATE_TIME   = DateTime.Now;
                                modelTestAllocation.F_OPERATOR_ID   = AppGlobal.GUserId;
                                modelTestAllocation.F_OPERATIONTIME = DateTime.Now;
                                modelTestAllocation.F_DEL           = 0;
                                bllTestAllocation.Add_KHD(modelTestAllocation);
                            }
                        }

                        saveflag = saveflag + 10;
                    }
                }

                //判断试验参数数据填写的值是否有效
                if (judgeTestCommParInfo())
                {
                    //试验参数数据填写值有效,保存
                    ProxyBllTEST_PAR_VALUE_KHD bllTestParValue = new ProxyBllTEST_PAR_VALUE_KHD();
                    //删除该任务编号的试验开始命令参数值
                    bllTestParValue.DropByTaskId(now_taskId);

                    for (int i = 0; i < _TestCommStartPar.Rows.Count; i++)
                    {
                        var ModelTEST_PAR_VALUE_KHD = new ModelTEST_PAR_VALUE_KHD();
                        ModelTEST_PAR_VALUE_KHD.F_TASK_ID = now_taskId;
                        //程序代码:在客户端表中备用,均填写为000
                        ModelTEST_PAR_VALUE_KHD.F_PROGRAM_CODE  = "000";
                        ModelTEST_PAR_VALUE_KHD.F_SENDPAR_NAME  = _TestCommStartPar.Rows[i]["F_SENDPAR_NAME"].ToString();
                        ModelTEST_PAR_VALUE_KHD.F_SENDPAR_VALUE = _TestCommStartPar.Rows[i]["F_SENDPAR_VALUE"].ToString();
                        //ModelTEST_PAR_VALUE_KHD.F_SENDPAR_UNIT = _TestCommStartPar.Rows[i]["F_PAR_UNIT"].ToString();
                        ModelTEST_PAR_VALUE_KHD.F_SENDORDER     = Convert.ToInt16(_TestCommStartPar.Rows[i]["colSENDORDER"].ToString());
                        ModelTEST_PAR_VALUE_KHD.F_CREATE_TIME   = DateTime.Now;
                        ModelTEST_PAR_VALUE_KHD.F_OPERATOR_ID   = AppGlobal.GUserId;
                        ModelTEST_PAR_VALUE_KHD.F_OPERATIONTIME = DateTime.Now;
                        ModelTEST_PAR_VALUE_KHD.F_DEL           = 0;

                        bllTestParValue.Add(ModelTEST_PAR_VALUE_KHD);
                    }
                    saveflag = saveflag + 100;
                }
                //根据saveflag的标志信息
                if (saveflag == 111) //试验基础信息、试验样品信息、试验参数信息均保存完成
                {
                    MessageBox.Show("任务编号:" + now_taskId + "的试验基础信息、试验样品信息、试验参数信息保存完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (saveflag == 110)//试验样品信息、试验参数信息均保存完成
                {
                    MessageBox.Show("任务编号:" + now_taskId + "的试验样品信息、试验参数信息保存完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (saveflag == 101)//试验基础信息、试验参数信息均保存完成
                {
                    MessageBox.Show("任务编号:" + now_taskId + "的试验基础信息、试验参数信息保存完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (saveflag == 11) //试验基础信息、试验样品信息保存完成
                {
                    MessageBox.Show("任务编号:" + now_taskId + "的试验基础信息、试验样品信息保存完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (saveflag == 100) //试验参数信息保存完成
                {
                    MessageBox.Show("任务编号:" + now_taskId + "的试验参数信息保存完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (saveflag == 10) //试验样品信息保存完成
                {
                    MessageBox.Show("任务编号:" + now_taskId + "的试验样品信息保存完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (saveflag == 1) //试验基础信息保存完成
                {
                    MessageBox.Show("任务编号:" + now_taskId + "的试验基础信息保存完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                if (saveflag != 0)
                {
                    initData();
                    BindGridview();
                    string tempstr = "";;
                    for (int i = 0; i < lstTasklist.ItemCount; i++)
                    {
                        tempstr = lstTasklist.Items[i].ToString();
                        if (tempstr.Substring(0, tempstr.IndexOf("_")).Equals(now_taskId))
                        {
                            lstTasklist.SelectedIndex = i;
                            break;;
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 删除任务按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDelete_Click(object sender, EventArgs e)
        {
            string now_taskId = "";

            now_taskId = txtTaskId.Text;

            if (now_taskId.Trim().Equals(""))
            {
                MessageBox.Show("要删除的任务编号为空,不能执行试验任务删除操作!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (!selecttaskinfo.Equals("") && selecttaskinfo.IndexOf("已分配") > 0)
            {
                MessageBox.Show("要删除的任务编号中存在已分配样品,先到上位机系统清除该任务分配信息后,方可执行本试验任务的删除操作!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            DialogResult dialogResult = XtraMessageBox.Show("确定要删除试验任务编号为:" + now_taskId + "的试验任务吗?", "选择", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dialogResult == DialogResult.No)
            {
                return;
            }
            else
            {
                ProxyBllTEST_INFO blltest_info = new ProxyBllTEST_INFO();
                //判断试验任务状态,只有F_TEST_STATUS=10的试验任务编号
                DataSet dsTestInfo = blltest_info.GetListByTaskId(now_taskId);
                if (dsTestInfo != null)
                {
                    string strTestStatus = dsTestInfo.Tables[0].Rows[0]["F_TEST_STATUS"].ToString().Trim();
                    //试验任务处于未开始状态
                    if (strTestStatus.Equals("10"))
                    {
                        //获取试验任务的已分配样品数量,已分配样品数量为0的试验任务,方可执行删除操作

                        //删除试验任务基本信息
                        blltest_info.Drop(now_taskId);
                        //删除试验试验任务样品信息
                        ProxyBllTEST_SAMPLE_INFO blltestSampleInfo = new ProxyBllTEST_SAMPLE_INFO();
                        blltestSampleInfo.DropByTaskId(now_taskId);
                        //删除试验任务参数信息
                        ProxyBllTEST_PAR_VALUE_KHD blltestCommParInfo = new ProxyBllTEST_PAR_VALUE_KHD();
                        blltestCommParInfo.DropByTaskId(now_taskId);
                        //删除试验任务
                        ProxyBllTESINFODB blltestDB = new ProxyBllTESINFODB();
                        blltestDB.Drop(now_taskId);
                        //删除样品分配表数据
                        ProxyBllTEST_ALLOCATION bllTestAllocation = new ProxyBllTEST_ALLOCATION();
                        bllTestAllocation.DropWhere(" F_TEST_TASK_ID='" + now_taskId + "' ");
                        //读取未开始试验的试验任务
                        BindGridview();
                    }
                    else
                    {
                        if (strTestStatus.Substring(0, 1).Equals("2"))
                        {
                            MessageBox.Show("该试验任务目前处于运行状态,不能执行删除操作!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        else if (strTestStatus.Substring(0, 1).Equals("6"))
                        {
                            MessageBox.Show("该试验任务目前处于结束状态,不能执行删除操作!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                    }
                }
            }
        }