Example #1
0
        //插入资料用
        public static IList<EY_Scale_Value> GetRegNo1(EY_Scale_Value_PK id)
        {
            using (ISession session = SessionHelper.GetSession())
            {

                IQuery query = session.CreateQuery("from EY_Scale_Value as a  where  a.Id = :s ");
                query.SetParameter("s", id);
                return query.List<EY_Scale_Value>();
            }
        }
Example #2
0
        public void Writelog(string Oldvalue, string Newvalue, string matrname, EY_Scale_Value_PK idd)
        {
            IList<EY_Scale_Value> zzz = EY_Scale_Value_Dao.GetRegNo1(idd);
                foreach (EY_Scale_Value t in zzz)
                {

                    EY_DataChange_Log LOG = new EY_DataChange_Log();
                    LOG.OldValue = Oldvalue;
                    LOG.NewValue = Newvalue;
                    LOG.Operator1 = textBoxX4.Text;
                    LOG.Date = System.DateTime.Now;
                    LOG.RegNo = t.Id.RegNo;
                    LOG.CheckNo = t.Id.CheckNo;
                    LOG.MatrName = t.Matrname;
                    LOG.RowName = matrname;

                    EY_DataChange_Log_DAO.Save(LOG);

                }
        }
Example #3
0
        public static void Update_ToErpFlag(EY_Scale_Value_PK spl, string st)
        {
            using (ISession session = SessionHelper.GetSession())
            {

                IQuery query = session.CreateQuery("update  EY_Scale_Value as a set a.ToErpFlag = :t where a.Id= :s ");
                query.SetParameter("s", spl);
                query.SetString("t", st);
                //query.SetString("k", cell);
                query.ExecuteUpdate();
            }
        }
Example #4
0
        public static IList<EY_Scale_Value> Update_Status(EY_Scale_Value_PK spl  , string st)
        {
            using (ISession session = SessionHelper.GetSession())
            {

                IQuery query = session.CreateQuery("update  EY_Scale_Value as a set a.Status = :t where a.Id= :s and a.FinalValue !='' and a.FinalValue != 0");
                query.SetParameter("s", spl);
                query.SetString("t", st);
                //query.SetString("k", cell);
                query.ExecuteUpdate();

                // return query.List<EY_Scale_Value>();
               return null;
            }
        }
Example #5
0
        public static IList<EY_Scale_Value> Update_OnlyValue(EY_Scale_Value_PK spl,decimal finalvalue)
        {
            using (ISession session = SessionHelper.GetSession())
            {

                IQuery query = session.CreateQuery("update  EY_Scale_Value as a set a.FinalValue=:t where  a.id= :s");
                query.SetParameter("s", spl);
                query.SetDecimal("t", finalvalue);
                query.ExecuteUpdate();

               // return query.List<EY_Scale_Value>();
                return null;
            }
        }
Example #6
0
        //上传ERP
        private void buttonX1_Click(object sender, EventArgs e)
        {
            string mess = "";
            int k = 0;

            int count = Convert.ToInt32(this.dataGridViewX1.Rows.Count.ToString());

            for (int i = 0; i < count; i++)
            {
                DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)this.dataGridViewX1.Rows[i].Cells["Column2"];

                Boolean flag = Convert.ToBoolean(checkCell.Value);

                if (flag == true)
                {

                    if (this.dataGridViewX1.Rows[i].Cells[6].Value.ToString().Trim() == "未上传")
                    {

                        string date = Convert.ToDateTime(this.dataGridViewX1.Rows[i].Cells[1].Value).ToString("yyyyMMddHHmmss").Substring(0,8).Trim();
                        string time = Convert.ToDateTime(this.dataGridViewX1.Rows[i].Cells[1].Value).ToString("yyyyMMddHHmmss").Substring(8, 6).Trim();
                        double water = Convert.ToDouble(this.dataGridViewX1.Rows[i].Cells[5].Value);
                        string str1 = water.ToString("0.00");
                        mess = "N" + "###" + this.dataGridViewX1.Rows[i].Cells[2].Value.ToString().Trim() + "###" + str1 + "###" + date + "###" + time;
                        tbdipdo tbdipdo = new tbdipdo();
                        tbdipdo.TimeStamp = Convert.ToDecimal(DateTime.Now.ToString("yyyyMMddHHmmss"));
                        tbdipdo.Status = "N";
                        tbdipdo.SerialNo = Convert.ToDecimal(k);

                        tbdipdo.Header = "192.168.100.92" + "PJKFPTC" + DateTime.Now.ToString("yyyyMMddHHmmss");
                        tbdipdo.QueueId = "PJKFPTC";
                        tbdipdo.Data = mess;
                        tbdipdo_DAO.TBDIPDOSAVE(tbdipdo);

                        try
                        {
                            EY_Scale_Value_PK SPL = new EY_Scale_Value_PK();
                            SPL.RegNo = Convert.ToString(this.dataGridViewX1.Rows[i].Cells[2].Value);
                            SPL.CheckNo = Convert.ToString(this.dataGridViewX1.Rows[i].Cells[3].Value);
                            EY_Scale_Value_Dao.Update_ToErpFlag(SPL, "1");

                        }
                        catch (Exception ex)

                        {
                            MessageBox.Show(ex.Message);
                        }

                        //EY_Scale_Value_PK SPL = new EY_Scale_Value_PK();
                        //SPL.RegNo = Convert.ToString(this.dataGridViewX1.Rows[i].Cells[2].Value);
                        //SPL.CheckNo = Convert.ToString(this.dataGridViewX1.Rows[i].Cells[3].Value);
                        //EY_Scale_Value_Dao.Update_ToErpFlag(SPL, "1");
                        k++;

                    }

                }

            }

            MessageBox.Show("上传成功" + k.ToString() + "笔数据");

            IList<EY_Scale_Value> EY_Scale_Value = EY_Scale_Value_Dao.GetScaleToErp("0");

            displaydatagridview(EY_Scale_Value);
        }
Example #7
0
        /// <summary>
        /// 计算最终结果
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonX5_Click(object sender, EventArgs e)
        {
            int Row = dataGridViewX1.Rows.GetRowCount(DataGridViewElementStates.Displayed) - 1;

                if (Row < 1)
                {
                    //MessageBox.Show("没有数据可以ji", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                Decimal finalvalue;

                int ss = EY_Scale_Value_Status();
                if (ss == 0)
                {

                    int rowcount = dataGridViewX1.SelectedRows.Count;
                    //int RowCount = dataGridViewX1.Rows.GetRowCount(DataGridViewElementStates.Displayed) - 1;
                    for (int i = 0; i < rowcount; i++)
                    {
                        Decimal watervalue = 0, Min0 = 0;

                        Decimal Min = Convert.ToDecimal(dataGridViewX1.SelectedRows[i].Cells[6].Value);
                        Decimal hengwgt2 = Convert.ToDecimal(dataGridViewX1.SelectedRows[i].Cells[7].Value);
                        Decimal Min1 = Convert.ToDecimal(dataGridViewX1.SelectedRows[i].Cells[8].Value);
                        Decimal hengwgt4 = Convert.ToDecimal(dataGridViewX1.SelectedRows[i].Cells[9].Value);
                        if (Min > 0)
                            Min0 = Min;
                        if (hengwgt2 < Min0 && hengwgt2 > 0)
                            Min0 = hengwgt2;
                        if (Min1 < Min0 && Min1 > 0)
                            Min0 = Min1;
                        if (hengwgt4 < Min0 && hengwgt4 > 0)
                            Min0 = hengwgt4;

                        Decimal final = (Convert.ToDecimal(dataGridViewX1.SelectedRows[i].Cells[4].Value) + Convert.ToDecimal(dataGridViewX1.SelectedRows[i].Cells[5].Value) - Min0) * 100 / Convert.ToDecimal(dataGridViewX1.SelectedRows[i].Cells[5].Value);

                        // IList<MTSICS_VO.EY_MatrTable> MatrTable = new List<EY_MatrTable>();
                        if (Convert.ToString(dataGridViewX1.SelectedRows[i].Cells[13].Value) != "DB")
                        {

                            string matrname = Convert.ToString(dataGridViewX1.SelectedRows[i].Cells[3].Value);
                            IList<EY_MatrTable> regNoList = EY_MatrTable_DAO.GetMatrTableWaterValue(matrname);
                            foreach (EY_MatrTable t in regNoList)
                            {
                                if (Convert.ToString(dataGridViewX1.SelectedRows[i].Cells[13].Value) == "XY")
                                {
                                    if (t.Water_Range_Less == 8 && t.Water_Range_Grater == 8)
                                        watervalue = t.Water_Value;

                                }

                                if ((t.Water_Range_Less == 0) && (t.Water_Range_Grater == 0))
                                {
                                    watervalue = t.Water_Value;

                                }

                                //if (final <= t.Water_Range_Less && final > t.Water_Range_Grater &&( t.Water_Range_Less < final && final <= t.Water_Range_Grater))
                                //    watervalue = t.Water_Value;
                                if (t.Water_Range_Less <= final && final < t.Water_Range_Grater)
                                    watervalue = t.Water_Value;
                                //if (final > t.Water_Range_Grater)
                                //    watervalue = t.Water_Value;

                            }

                            finalvalue = final + watervalue;
                        }
                        else
                        {
                            finalvalue = final;
                        }

                        dataGridViewX1.SelectedRows[i].Cells[10].Value = finalvalue;

                        EY_Scale_Value_PK SPL = new EY_Scale_Value_PK();

                        SPL.RegNo = Convert.ToString(dataGridViewX1.SelectedRows[i].Cells[1].Value);
                        SPL.CheckNo = Convert.ToString(dataGridViewX1.SelectedRows[i].Cells[2].Value);

                        //string regNo = Convert.ToString(dataGridViewX1.SelectedRows[i].Cells[6].Value);
                        //  EY_Scale_Value_Dao.Update_OnlyValue(SPL, finalvalue);

                        //IList<EY_Scale_Value> zz = EY_Scale_Value_Dao.GetRegNo1(SPL);
                        //foreach (EY_Scale_Value t in zz)
                        // t.FinalValue = finalvalue;

                        EY_Scale_Value_Dao.Update_OnlyValue(SPL, finalvalue);

                    }

                    //saveIt();
                }
                buttonX3.Focus();
        }
Example #8
0
        //修改数据
        private void buttonX2_Click(object sender, EventArgs e)
        {
            int Row = dataGridViewX1.Rows.GetRowCount(DataGridViewElementStates.Displayed) - 1;

                if (Row < 1)
                {
                    MessageBox.Show("没有数据可以修改", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

              int ss = EY_Scale_Value_Status();
              if (ss == 0)
              {

                  try
                  {
                      int RowCount = dataGridViewX1.Rows.GetRowCount(DataGridViewElementStates.Displayed) - 1;

                      for (int i = 0; i < RowCount; i++)
                      {
                          EY_Scale_Value EY_Scale_Value_Vo = new EY_Scale_Value();
                          EY_Scale_Value_PK ssss = new EY_Scale_Value_PK();

                          ssss.RegNo = Convert.ToString(dataGridViewX1.Rows[i].Cells[1].Value);
                          ssss.CheckNo = Convert.ToString(dataGridViewX1.Rows[i].Cells[2].Value);

                          EY_Scale_Value_Vo.Id = ssss;

                          IList<EY_Scale_Value> zzz = EY_Scale_Value_Dao.GetRegNo1(ssss);
                          foreach (EY_Scale_Value t in zzz)
                          {

                           EY_Scale_Value_Vo.Matrname = t.Matrname;
                           EY_Scale_Value_Vo.Date = t.Date;

                          EY_Scale_Value_Vo.PanWgt = Convert.ToDecimal(dataGridViewX1.Rows[i].Cells[4].Value);
                          if (EY_Scale_Value_Vo.PanWgt != t.PanWgt)
                          {
                            Writelog(Convert.ToString(t.PanWgt), Convert.ToString(EY_Scale_Value_Vo.PanWgt), "盘重",ssss);
                            EY_Scale_Value_Vo.Flag = t.Flag + 1;
                           }

                          EY_Scale_Value_Vo.YangWgt = Convert.ToDecimal(dataGridViewX1.Rows[i].Cells[5].Value);
                          if (EY_Scale_Value_Vo.YangWgt != t.YangWgt)
                          {
                              Writelog(Convert.ToString(t.YangWgt), Convert.ToString(EY_Scale_Value_Vo.YangWgt), "样重", ssss);
                              EY_Scale_Value_Vo.Flag = t.Flag + 1;
                          }
                          EY_Scale_Value_Vo.HengWgt1 = Convert.ToDecimal(dataGridViewX1.Rows[i].Cells[6].Value);
                          if (EY_Scale_Value_Vo.HengWgt1 != t.HengWgt1)
                          {
                              Writelog(Convert.ToString(t.HengWgt1), Convert.ToString(EY_Scale_Value_Vo.HengWgt1), "恒重1", ssss);
                              EY_Scale_Value_Vo.Flag = t.Flag + 1;
                          }
                          EY_Scale_Value_Vo.HengWgt2 = Convert.ToDecimal(dataGridViewX1.Rows[i].Cells[7].Value);
                          if (EY_Scale_Value_Vo.HengWgt2 != t.HengWgt2)
                          {
                              Writelog(Convert.ToString(t.HengWgt2), Convert.ToString(EY_Scale_Value_Vo.HengWgt2), "恒重2", ssss);
                              EY_Scale_Value_Vo.Flag = t.Flag + 1;
                          }
                          EY_Scale_Value_Vo.HengWgt3 = Convert.ToDecimal(dataGridViewX1.Rows[i].Cells[8].Value);
                          if (EY_Scale_Value_Vo.HengWgt3 != t.HengWgt3)
                          {
                              Writelog(Convert.ToString(t.HengWgt3), Convert.ToString(EY_Scale_Value_Vo.HengWgt3), "恒重3", ssss);
                              EY_Scale_Value_Vo.Flag = t.Flag + 1;
                          }
                          EY_Scale_Value_Vo.HengWgt4 = Convert.ToDecimal(dataGridViewX1.Rows[i].Cells[9].Value);
                          if (EY_Scale_Value_Vo.HengWgt4 != t.HengWgt4)
                          {
                              Writelog(Convert.ToString(t.HengWgt4), Convert.ToString(EY_Scale_Value_Vo.HengWgt4), "恒重4", ssss);
                              EY_Scale_Value_Vo.Flag = t.Flag + 1;
                          }
                          EY_Scale_Value_Vo.FinalValue = Convert.ToDecimal(dataGridViewX1.Rows[i].Cells[10].Value);
                          if (EY_Scale_Value_Vo.FinalValue != t.FinalValue)
                          {
                              Writelog(Convert.ToString(t.FinalValue), Convert.ToString(EY_Scale_Value_Vo.FinalValue), "结果", ssss);
                              EY_Scale_Value_Vo.Flag = t.Flag + 1;
                          }
                          EY_Scale_Value_Vo.Operator1 = t.Operator1;
                          EY_Scale_Value_Vo.Operator2 = Convert.ToString(dataGridViewX1.Rows[i].Cells[12].Value);
                          if (EY_Scale_Value_Vo.Operator2 != t.Operator2)
                          {
                              Writelog(Convert.ToString(t.Operator2), Convert.ToString(EY_Scale_Value_Vo.Operator2), "备注", ssss);
                              EY_Scale_Value_Vo.Flag = t.Flag + 1;
                          }
                          EY_Scale_Value_Vo.Mem1 = Convert.ToString(dataGridViewX1.Rows[i].Cells[13].Value);
                          if (EY_Scale_Value_Vo.Mem1 != t.Mem1)
                          {
                              Writelog(Convert.ToString(t.Mem1 ), Convert.ToString(EY_Scale_Value_Vo.Mem1), "备注", ssss);
                              EY_Scale_Value_Vo.Flag = t.Flag + 1;
                          }
                          // EY_Scale_Value_Vo.ToErpFlag = "0";
                          //数据被修改过

                               EY_Scale_Value_Vo.Status = t.Status;
                               EY_Scale_Value_Vo.ToErpFlag = t.ToErpFlag;
                               //EY_Scale_Value_Vo.Mem1 = t.Mem1;
                          }

                          EY_Scale_Value_Dao.Update(EY_Scale_Value_Vo);

                      }

                      MessageBox.Show("修改数据成功");

                  }
                  catch (Exception ex)
                  {
                      MessageBox.Show(ex.Message);

                  }

              }

              else {

                  MessageBox.Show("已产制报表,无法修改数据,请联系管理员");
              }
        }
Example #9
0
        //保存数据
        private void buttonX1_Click(object sender, EventArgs e)
        {
            try
                {
                    int RowCount = dataGridViewX1.Rows.GetRowCount(DataGridViewElementStates.Displayed) - 1;

                    for (int i = 0; i < RowCount; i++)
                    {
                        EY_Scale_Value EY_Scale_Value_Vo = new EY_Scale_Value();
                        EY_Scale_Value_PK spk = new EY_Scale_Value_PK();
                       // EY_Scale_Value_Vo.Date = Convert.ToDateTime(dataGridViewX1.Rows[i].Cells[0].Value);
                        EY_Scale_Value_Vo.Date = Convert.ToDateTime(dataGridViewX1.Rows[i].Cells[0].Value);
                        spk.RegNo = Convert.ToString(dataGridViewX1.Rows[i].Cells[1].Value);
                        spk.CheckNo = Convert.ToString(dataGridViewX1.Rows[i].Cells[2].Value);
                       // EY_Scale_Value_Vo.RegNo = Convert.ToString(dataGridViewX1.Rows[i].Cells[1].Value);
                       // EY_Scale_Value_Vo.CheckNo = Convert.ToString(dataGridViewX1.Rows[i].Cells[2].Value);
                        EY_Scale_Value_Vo.Id = spk;
                        EY_Scale_Value_Vo.Matrname = Convert.ToString(dataGridViewX1.Rows[i].Cells[3].Value);
                        EY_Scale_Value_Vo.PanWgt = Convert.ToDecimal(dataGridViewX1.Rows[i].Cells[4].Value);

                        EY_Scale_Value_Vo.YangWgt = Convert.ToDecimal(dataGridViewX1.Rows[i].Cells[5].Value);
                        EY_Scale_Value_Vo.HengWgt1 = Convert.ToDecimal(dataGridViewX1.Rows[i].Cells[6].Value);
                        EY_Scale_Value_Vo.HengWgt2 = Convert.ToDecimal(dataGridViewX1.Rows[i].Cells[7].Value);
                        EY_Scale_Value_Vo.HengWgt3 = Convert.ToDecimal(dataGridViewX1.Rows[i].Cells[8].Value);
                        EY_Scale_Value_Vo.HengWgt4 = Convert.ToDecimal(dataGridViewX1.Rows[i].Cells[9].Value);
                        EY_Scale_Value_Vo.FinalValue = Convert.ToDecimal(dataGridViewX1.Rows[i].Cells[10].Value);
                        EY_Scale_Value_Vo.Operator1 = Convert.ToString(dataGridViewX1.Rows[i].Cells[11].Value);
                        EY_Scale_Value_Vo.Operator2 = Convert.ToString(dataGridViewX1.Rows[i].Cells[12].Value);
                        EY_Scale_Value_Vo.Mem1 = Convert.ToString(dataGridViewX1.Rows[i].Cells[13].Value);
                        ////上传ERP标志位
                        //EY_Scale_Value_Vo.ToErpFlag = "0";
                        ////修改标志位
                        //EY_Scale_Value_Vo.Flag = "0";
                        ////产制报表后变Y后数据不可修改
                        //EY_Scale_Value_Vo.Status = "N";

                        if (EY_Scale_Value_Dao.GetRegNo1(EY_Scale_Value_Vo.Id).Count==0)

                            {

                                EY_Scale_Value_Vo.ToErpFlag = "0";
                                EY_Scale_Value_Vo.Flag = 0;
                                EY_Scale_Value_Vo.Status = "N";

                                EY_Scale_Value_Dao.Create(EY_Scale_Value_Vo);

                             }else
                            {
                                EY_Scale_Value_Dao.Update(EY_Scale_Value_Vo);

                            }

                    }
                    MessageBox.Show("保存数据成功");

                }
                catch(Exception ex)
                {
                    MessageBox.Show("该批次已保存,请勿重复点击");
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    SessionHelper.CloseSession();
                }
        }
Example #10
0
        //后台保存数据用
        private void saveIt()
        {
            int ss = EY_Scale_Value_Status();
                if (ss == 0)
                {
                    try
                    {
                        int RowCount = dataGridViewX1.Rows.GetRowCount(DataGridViewElementStates.Displayed) - 1;

                        for (int i = 0; i < RowCount; i++)
                        {
                            EY_Scale_Value EY_Scale_Value_Vo = new EY_Scale_Value();
                            EY_Scale_Value_PK spk = new EY_Scale_Value_PK();
                            // EY_Scale_Value_Vo.Date = Convert.ToDateTime(dataGridViewX1.Rows[i].Cells[0].Value);
                            EY_Scale_Value_Vo.Date = Convert.ToDateTime(dataGridViewX1.Rows[i].Cells[0].Value);
                            spk.RegNo = Convert.ToString(dataGridViewX1.Rows[i].Cells[1].Value);
                            spk.CheckNo = Convert.ToString(dataGridViewX1.Rows[i].Cells[2].Value);
                            // EY_Scale_Value_Vo.RegNo = Convert.ToString(dataGridViewX1.Rows[i].Cells[1].Value);
                            // EY_Scale_Value_Vo.CheckNo = Convert.ToString(dataGridViewX1.Rows[i].Cells[2].Value);
                            EY_Scale_Value_Vo.Id = spk;
                            EY_Scale_Value_Vo.Matrname = Convert.ToString(dataGridViewX1.Rows[i].Cells[3].Value);
                            EY_Scale_Value_Vo.PanWgt = Convert.ToDecimal(dataGridViewX1.Rows[i].Cells[4].Value);

                            EY_Scale_Value_Vo.YangWgt = Convert.ToDecimal(dataGridViewX1.Rows[i].Cells[5].Value);
                            EY_Scale_Value_Vo.HengWgt1 = Convert.ToDecimal(dataGridViewX1.Rows[i].Cells[6].Value);
                            EY_Scale_Value_Vo.HengWgt2 = Convert.ToDecimal(dataGridViewX1.Rows[i].Cells[7].Value);
                            EY_Scale_Value_Vo.HengWgt3 = Convert.ToDecimal(dataGridViewX1.Rows[i].Cells[8].Value);
                            EY_Scale_Value_Vo.HengWgt4 = Convert.ToDecimal(dataGridViewX1.Rows[i].Cells[9].Value);
                            EY_Scale_Value_Vo.FinalValue = Convert.ToDecimal(dataGridViewX1.Rows[i].Cells[10].Value);
                            EY_Scale_Value_Vo.Operator1 = Convert.ToString(dataGridViewX1.Rows[i].Cells[11].Value);
                            EY_Scale_Value_Vo.Operator2 = Convert.ToString(dataGridViewX1.Rows[i].Cells[12].Value);
                            EY_Scale_Value_Vo.Mem1 = Convert.ToString(dataGridViewX1.Rows[i].Cells[13].Value);
                            EY_Scale_Value_Vo.ToErpFlag = "0";
                            EY_Scale_Value_Vo.Flag = 0;
                            EY_Scale_Value_Vo.Status = "N";

                            if (EY_Scale_Value_Dao.GetRegNo1(EY_Scale_Value_Vo.Id).Count == 0)
                            {

                                //EY_Scale_Value_Vo.ToErpFlag = "0";
                                //EY_Scale_Value_Vo.Flag = "0";
                                //EY_Scale_Value_Vo.Status = "N";
                                EY_Scale_Value_Dao.Create(EY_Scale_Value_Vo);

                            }
                            else
                            {
                                EY_Scale_Value_Dao.Update(EY_Scale_Value_Vo);

                            }

                        }
                        // MessageBox.Show("保存数据成功");

                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("saveit方法报错");
                        MessageBox.Show(ex.Message);
                    }
                    //finally
                    //{
                    //    SessionHelper.CloseSession();
                    //}

                }
        }
Example #11
0
        //获取数据库数据,产制报表
        private DataTable GetData()
        {
            DataTable table = new DataTable("table1");

                //使用自动增量时必须设置为SqlInt64
                //table.Columns.Add("id", typeof(SqlInt64));
                //table.Columns["id"].AutoIncrement = true;

               // table.Columns.Add("id", typeof(SqlInt32));
                //设置主键,主键可以是一个或者多个DataColumns对象组成的数组
                DataColumn[] key = new DataColumn[2];
              //  key[0] = table.Columns["id"];
              //  table.PrimaryKey = key;
                //SqlString相当于SQL SERVER类型中的nvarchar
                MessageBox.Show("报表产制中,产制完毕会弹出,请稍候....");
                table.Columns.Add("日期", typeof(SqlDateTime));
                table.Columns.Add("案件接收编号", typeof(SqlString));

                 table.Columns.Add("检验批号", typeof(SqlString));
                table.Columns.Add("料名", typeof(SqlString));
                //key[0] = table.Columns["案件接收编号"];
                //key[1] = table.Columns["中文名称"];
                //table.PrimaryKey = key;

                //table.Columns.Add("料名", typeof(SqlString));
                table.Columns.Add("盘重", typeof(SqlDecimal));
                table.Columns.Add("样重", typeof(SqlDecimal));
                table.Columns.Add("恒重1", typeof(SqlDecimal));
                table.Columns.Add("恒重2", typeof(SqlDecimal));
                table.Columns.Add("恒重3", typeof(SqlDecimal));
                table.Columns.Add("恒重4", typeof(SqlDecimal));
                table.Columns.Add("结果", typeof(SqlDecimal));
                table.Columns.Add("检测员1", typeof(SqlString));
                table.Columns.Add("检测员2", typeof(SqlString));
                table.Columns.Add("备注", typeof(SqlString));
                //table.Columns.Add("年龄", typeof(SqlInt32));
                //table.Columns.Add("出生日期", typeof(SqlDateTime));
                DateTime tem = dateTimePicker2.Value;
                string year = tem.Year.ToString();
                string month = tem.Month.ToString();
                string day = tem.Day.ToString();
                string date = year + "/" + month + "/" + day;
                MessageBox.Show(date + " 00:00:00");
                String ss = date + " 00:00:00";
               // String ss = tem.ToString().Substring(0, 9).Trim() + " 00:00:00";
                tem = DateTime.Parse(ss);
                IList<EY_Batch> allBatch = EY_Batch_DAO.LoadByTime(tem, tem.AddHours(24));
                int i = 0;
                foreach (EY_Batch t in allBatch)
                {
                    IList<EY_RegNo_DI> reg = EY_RegNo_DI_DAO.GetRegNo1(t.BatchNo);
                    foreach (EY_RegNo_DI a in reg)
                    {
                        EY_Scale_Value_PK id = new EY_Scale_Value_PK();
                        id.RegNo = a.RegNo;
                        id.CheckNo = a.CheckNo;

                       // EY_Scale_Value_Dao.Update_Status(id , "Y");
                        IList<EY_Scale_Value> scale = EY_Scale_Value_Dao.GetRegNo(id);
                        foreach (EY_Scale_Value b in scale)
                        {
                            i++;
                            DataRow row = table.NewRow();

                         //   row["id"] = 1 + i;
                            row["日期"] = b.Date;
                            row["案件接收编号"] = b.Id.RegNo;
                            row["检验批号"] = b.Id.CheckNo;

                            row["料名"] = b.Matrname;

                            //IList<EY_MatrTable> MatrNameList = EY_MatrTable_DAO.GetMatrName(ss[1].Trim());

                            //foreach (EY_MatrTable s in MatrNameList)
                            //{
                            //     row["料名"] = s.MatrName;

                            //}

                            row["盘重"] = b.PanWgt;
                            row["样重"] = b.YangWgt;
                            row["恒重1"] = b.HengWgt1;
                            row["恒重2"] = b.HengWgt2;
                            row["恒重3"] = b.HengWgt3;
                            row["恒重4"] = b.HengWgt4;
                            row["结果"] = b.FinalValue;
                            row["检测员1"] = b.Operator1 + "";

                            row["检测员2"] = b.Operator2+"";
                            row["备注"] = b.Mem1 + "";

                            table.Rows.Add(row);

                        }
                        EY_Scale_Value_Dao.Update_Status(id, "Y");

                    }
                }

              //  row["出生日期"] = new DateTime(1990, 10, 23);

                return table;
        }
Example #12
0
        //判断数据是否产制报表,如果产制报表不可修改
        private int EY_Scale_Value_Status()
        {
            int flag = 0;
                EY_Scale_Value EY_Scale_Value = new EY_Scale_Value();
                EY_Scale_Value_PK spk = new EY_Scale_Value_PK();

                spk.RegNo = Convert.ToString(dataGridViewX1.CurrentRow.Cells[1].Value);
                spk.CheckNo = Convert.ToString(dataGridViewX1.CurrentRow.Cells[2].Value);
                EY_Scale_Value.Id = spk;

                IList<EY_Scale_Value> EY_Scale_value_Status = EY_Scale_Value_Dao.GetRegNo1(EY_Scale_Value.Id);
             foreach (EY_Scale_Value t in EY_Scale_value_Status)
             {
                 if (t.Status == "Y")
                 {
                    // MessageBox.Show("已产制报表,数据不可修改,请联系管理人员");
                     flag = 1;
                 }
            }
             return flag;
        }
Example #13
0
        /// <summary>
        /// 添加平行样
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonX8_Click(object sender, EventArgs e)
        {
            try
                {
                    EY_Scale_Value_PK spk = new EY_Scale_Value_PK();
                    spk.RegNo = Convert.ToString(dataGridViewX1.SelectedCells[1].Value);
                    spk.CheckNo = Convert.ToString(dataGridViewX1.SelectedCells[2].Value);
                    EY_RegNo_DI temVo = new EY_RegNo_DI();

                    IList<EY_RegNo_DI> regCount = new List<EY_RegNo_DI>();

                    regCount = EY_RegNo_DI_DAO.GetRegNoCount(spk.RegNo);

                    dataGridViewX1.Rows.Insert(dataGridViewX1.CurrentCell.RowIndex + 1, 1);
                    int RowCount1 = dataGridViewX1.Rows.GetRowCount(DataGridViewElementStates.Displayed) - 1;
                    int a = regCount.Count + 1;
                    dataGridViewX1.Rows[dataGridViewX1.CurrentCell.RowIndex + 1].Cells[0].Value = System.DateTime.Now;
                    dataGridViewX1.Rows[dataGridViewX1.CurrentCell.RowIndex + 1].Cells[1].Value = dataGridViewX1.SelectedCells[1].Value + "_" + a;
                    dataGridViewX1.Rows[dataGridViewX1.CurrentCell.RowIndex + 1].Cells[2].Value = dataGridViewX1.SelectedCells[2].Value;
                    dataGridViewX1.Rows[dataGridViewX1.CurrentCell.RowIndex + 1].Cells[3].Value = dataGridViewX1.SelectedCells[3].Value;
                    IList<EY_RegNo_DI> regList = new List<EY_RegNo_DI>();
                    regList = EY_RegNo_DI_DAO.GetRegNo3(Convert.ToString(dataGridViewX1.SelectedCells[1].Value));
                    temVo.RegNo = dataGridViewX1.SelectedCells[1].Value + "_" + a;
                    temVo.RevDateTime = DateTime.Now;
                    temVo.Status = "Y";
                    temVo.Batch = regList[0].Batch;
                    temVo.CheckNo = regList[0].CheckNo;
                    temVo.MatrNo = regList[0].MatrNo;
                    temVo.CName = regList[0].CName;

                    EY_RegNo_DI_DAO.Save(temVo);

                }
                catch
                {
                    MessageBox.Show("必须指定案件接收编号才能使用此功能");
                }

                finally
                {
                    SessionHelper.CloseSession();
                }
        }