示例#1
0
        private void CopyAdd(int id)
        {
            QualityTrackingEntity entity;

            try
            {
                QualityTrackingDAC dac = new QualityTrackingDAC();
                entity = dac.Select(id);
            }
            catch (Exception ex)
            {
                MessageBox.Show("读取数据库出错,请检查网络;\r\n原因:" + ex.Message);
                return;
            }
            if (entity != null)
            {
                frmQualityTracking frm = new frmQualityTracking();
                //修改模式
                frm.EditMode    = 1;
                frm.objTracking = entity;
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    Refresh();
                }
                frm.Dispose();
                frm = null;
            }
        }
示例#2
0
 private void Refresh()
 {
     InitHeader();
     try
     {
         QualityTrackingDAC           dac       = new QualityTrackingDAC();
         List <QualityTrackingEntity> lstResult = dac.Query(dtpStart.Value, dtpEnd.Value, batch.Text.Trim(), target.Text.Trim(), type.Text.Trim(), decision.Text.Trim());
         DataTable dt = ControlHelper.ConvertList2DataTable(lstResult);
         dataGridResult.DataSource = dt;
     }
     catch (Exception ex)
     {
         MessageBox.Show("读取数据库出错,请检查网络;\r\n原因:" + ex.Message);
     }
 }
示例#3
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = "Excel文件|*.xls";

            //设置默认文件类型显示顺序
            sfd.FilterIndex      = 1;
            sfd.RestoreDirectory = true;
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                DataTable dt;
                try
                {
                    QualityTrackingDAC           dac       = new QualityTrackingDAC();
                    List <QualityTrackingEntity> lstResult = dac.Query(dtpStart.Value, dtpEnd.Value, batch.Text.Trim(), target.Text.Trim(), type.Text, decision.Text);
                    dt = ControlHelper.ConvertList2ExcelTable(lstResult);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("读取数据库出错,请检查网络;\r\n原因:" + ex.Message);
                    return;
                }

                try
                {
                    NPOIHelper.Export(dt, "", sfd.FileName.ToString());
                }
                catch (Exception ex)
                {
                    MessageBox.Show("导出Excel出错;\r\n原因:" + ex.Message);
                    return;
                }
                MessageBox.Show("导出成功");
            }
        }
示例#4
0
        private void Remove(int id)
        {
            if (MessageBox.Show("确认是否删除当前记录?", "提示", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }
            int iRet;

            try
            {
                QualityTrackingDAC dac = new QualityTrackingDAC();
                iRet = dac.Delete(id);
            }
            catch (Exception ex)
            {
                MessageBox.Show("操作数据库出错,请检查网络;\r\n原因:" + ex.Message);
                return;
            }
            if (iRet > 0)
            {
                MessageBox.Show("删除成功");
                Refresh();
            }
        }
示例#5
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (!ControlHelper.isNumeric(length.Text))
            {
                MessageBox.Show("规格必须为数字!");
                length.Focus();
                return;
            }

            if (batch.Text.Trim().Length == 0)
            {
                MessageBox.Show("必须输入批号");
                batch.Focus();
                return;
            }

            try
            {
                SysDictDAC    dacSys    = new SysDictDAC();
                SysDictEntity objEntity = dacSys.Select("qtspec", specifications.Text.Trim());
                if (objEntity == null)
                {
                    SysDictEntity newSysEntity = new SysDictEntity();
                    newSysEntity.dictype   = "qtspec";
                    newSysEntity.dictvalue = specifications.Text.Trim();
                    dacSys.Add(newSysEntity);
                }

                objEntity = dacSys.Select("qtcategory", category.Text.Trim());
                if (objEntity == null)
                {
                    SysDictEntity newSysEntity = new SysDictEntity();
                    newSysEntity.dictype   = "qtcategory";
                    newSysEntity.dictvalue = category.Text.Trim();
                    dacSys.Add(newSysEntity);
                }

                objEntity = dacSys.Select("target", target.Text.Trim());
                if (objEntity == null)
                {
                    SysDictEntity newSysEntity = new SysDictEntity();
                    newSysEntity.dictype   = "target";
                    newSysEntity.dictvalue = target.Text.Trim();
                    dacSys.Add(newSysEntity);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("保存字典出错,请检查网络是否异常!\r\n原因如下:" + ex.Message);
            }


            QualityTrackingDAC dac = new QualityTrackingDAC();

            if (EditMode == 0 || EditMode == 1)
            {
                QualityTrackingEntity entity = new QualityTrackingEntity();
                entity.qtdate         = qtdate.Value;
                entity.category       = category.Text;
                entity.batch          = batch.Text;
                entity.specifications = specifications.Text;
                if (length.Text.Trim().Length == 0)
                {
                    entity.length = 0;
                }
                else
                {
                    entity.length = int.Parse(length.Text);
                }
                entity.volume          = volume.Text;
                entity.stripping1      = stripping1.Text;
                entity.stripping2      = stripping2.Text;
                entity.sample11        = sample11.Text;
                entity.sample12        = sample12.Text;
                entity.sample13        = sample13.Text;
                entity.sample21        = sample21.Text;
                entity.sample22        = sample22.Text;
                entity.sample23        = sample23.Text;
                entity.baseheight      = baseheight.Text;
                entity.measuredheight  = measuredheight.Text;
                entity.compositeheight = compositeheight.Text;
                entity.cutheight       = cutheight.Text;
                entity.bubblewater1    = bubblewater1.Text;
                entity.bubblewater2    = bubblewater2.Text;
                entity.bubbleoil       = bubbleoil.Text;
                entity.descrtiption    = descrtiption.Text;
                entity.loginid         = Global.LoginUser.loginid;
                entity.target          = target.Text;
                entity.elongation      = elongation.Text.Trim();
                entity.elongation1     = elongation1.Text.Trim();
                entity.type            = type.Text;
                entity.decision        = decision.Text;
                int id = 0;
                try
                {
                    id = dac.Insert(entity);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("新增出错,请检查网络是否异常!\r\n原因如下:" + ex.Message);
                }
                if (id > 0)
                {
                    if (MessageBox.Show("保存成功,是否继续添加?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        batch.Text = "";
                        qtdate.Focus();
                    }
                    else
                    {
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show("保存失败!");
                }
            }
            else
            {
                if (objTracking == null)
                {
                    MessageBox.Show("系统错误");
                    return;
                }

                objTracking.qtdate         = qtdate.Value;
                objTracking.category       = category.Text;
                objTracking.batch          = batch.Text;
                objTracking.specifications = specifications.Text;
                if (length.Text.Trim().Length == 0)
                {
                    objTracking.length = 0;
                }
                else
                {
                    objTracking.length = int.Parse(length.Text);
                }
                objTracking.volume          = volume.Text;
                objTracking.stripping1      = stripping1.Text;
                objTracking.stripping2      = stripping2.Text;
                objTracking.sample11        = sample11.Text;
                objTracking.sample12        = sample12.Text;
                objTracking.sample13        = sample13.Text;
                objTracking.sample21        = sample21.Text;
                objTracking.sample22        = sample22.Text;
                objTracking.sample23        = sample23.Text;
                objTracking.baseheight      = baseheight.Text;
                objTracking.measuredheight  = measuredheight.Text;
                objTracking.compositeheight = compositeheight.Text;
                objTracking.cutheight       = cutheight.Text;
                objTracking.bubblewater1    = bubblewater1.Text;
                objTracking.bubblewater2    = bubblewater2.Text;
                objTracking.bubbleoil       = bubbleoil.Text;
                objTracking.descrtiption    = descrtiption.Text;
                objTracking.loginid         = Global.LoginUser.loginid;
                objTracking.target          = target.Text;
                objTracking.elongation      = elongation.Text;
                objTracking.elongation1     = elongation1.Text;
                objTracking.type            = type.Text;
                objTracking.decision        = decision.Text;
                int id = 0;
                try
                {
                    id = dac.Update(objTracking);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("保存出错,请检查网络是否异常!\r\n原因如下:" + ex.Message);
                }
                if (id > 0)
                {
                    MessageBox.Show("保存成功");
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("保存失败!");
                }
            }
        }