示例#1
0
        /// <summary>
        /// 插入产品信息
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public int InsertProduction(ProductionMDL mdl)
        {
            int ret = 0;

            string strSql = string.Empty;

            try
            {
                ///DateTime theDate = DateTime.Now;
                // theDate.ToString("yyyy-MM-dd HH:mm:ss");
                string dateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                strSql = "insert into  production (lineid,brakename,brakeid,brakecode,createtime,factory,remark)" +
                         "values('{0}','{1}','{2}','{3}','{4}','{5}','{6}')";

                // strSql = string.Format(strSql, mdl.LineNum, mdl.ProductName, mdl.ProductID, mdl.ProductCode, dateTime, mdl.Factory, mdl.Remark);

                //ret = MySqlDBHelper.ExecuteNonQuery(MySqlDBHelper.Conn, CommandType.Text, strSql, null);
                ret = SQLiteDBHelper.ExecuteNonQuery(strSql);
                return(ret);
            }
            catch (Exception ex)
            {
                CLog.WriteErrLogInTrace(ex.Message);
                return(0);
            }
        }
示例#2
0
        //}

        public Hashtable GetProductCTTable2()
        {
            Hashtable ctTable = new Hashtable();

            try
            {
                DataSet dataSet = null;

                //string strSql = "SELECT * FROM tlb_product ORDER BY CREATE_TIME ASC";

                string strSql = "SELECT * FROM tlb_product ";

                dataSet = MySqlDBHelper.ExecuteDataSet(MySqlDBHelper.Conn, CommandType.Text, strSql);

                if (dataSet != null)
                {
                    foreach (DataRow row in dataSet.Tables[0].Rows)
                    {
                        ProductionMDL mdl  = ProductionMDL.ParseDataRow(row);
                        CTUnitMDL     unit = new CTUnitMDL();
                        unit.PN  = mdl.PN;
                        unit.CT  = mdl.CT;
                        unit.EMS = mdl.EMS;
                        unit.OP  = mdl.OP;
                        ctTable.Add(mdl.PN, unit);
                    }
                }

                return(ctTable);
            }
            catch
            {
                throw;
            }
        }
示例#3
0
        /// <summary>
        /// 插入产品信息
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public int InsertProduction(ProductionMDL mdl)
        {
            int ret = 0;

            string strSql = string.Empty;

            try
            {
                //DateTime theDate = DateTime.Now;
                //theDate.ToString("yyyy-MM-dd HH:mm:ss");

                strSql = "insert into  tlb_product (PN,PLID,NAME ,EMS,CREATE_TIME,CODE,TYPE,FACTORY,CT,OP,REMARK)" +
                         "values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}')";

                strSql = string.Format(strSql, mdl.PN, mdl.PLID, mdl.Name, mdl.EMS, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                                       , mdl.Code, mdl.CodeType, mdl.Factory, mdl.CT, mdl.OP, mdl.Remark);

                ret = MySqlDBHelper.ExecuteNonQuery(MySqlDBHelper.Conn, CommandType.Text, strSql, null);



                return(ret);
            }
            catch (Exception ex)
            {
                CLog.WriteErrLogInTrace(ex.Message);
                return(0);
            }
        }
示例#4
0
        private void btAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.txtName.Text.Trim().Length < 1)
                {
                    MessageBox.Show("请填写产品名称!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }

                if (this.txtID.Text.Trim().Length < 1)
                {
                    MessageBox.Show("请填填写产品ID!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }

                if (this.txtCode.Text.Trim().Length < 1)
                {
                    MessageBox.Show("请填填写产品编码!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }

                if (isUpdate)
                {
                    //Modidfy by guozq 2016-9-6
                    //production.LineNum = this.cbLineNum.SelectedIndex+1;
                    //production.ProductName = this.txtName.Text.Trim();
                    //production.ProductID = this.txtID.Text.Trim();
                    //production.ProductCode = this.txtCode.Text.Trim();
                    production.Factory = this.txtFactory.Text.Trim();
                    production.Remark  = this.txtRemark.Text.Trim();
                }
                else
                {
                    production = new ProductionMDL();
                    //production.LineNum = this.cbLineNum.SelectedIndex + 1;
                    //production.ProductName = this.txtName.Text.Trim();
                    //production.ProductID = this.txtID.Text.Trim();
                    //production.ProductCode = this.txtCode.Text.Trim();
                    production.Factory = this.txtFactory.Text.Trim();
                    production.Remark  = this.txtRemark.Text.Trim();
                }

                //info.Remark = this.txtRemark.Text.Trim();

                this.DialogResult = DialogResult.OK;

                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
示例#5
0
        /// <summary>
        /// 查询过去CTUNIT
        /// </summary>
        /// <param name="LineID"></param>
        /// <param name="ems"></param>
        /// <returns></returns>
        public CTUnitMDL GetCTUnit(string lineid, int ems)
        {
            CTUnitMDL unit = null;

            try
            {
                int id = 0;

                Int32.TryParse(lineid, out id);

                if (id <= 0)
                {
                    return(null);
                }


                string strSql = "SELECT * FROM tlb_product WHERE  PLID='{0}' AND EMS={1}";

                strSql = string.Format(strSql, id.ToString(), ems);

                DataSet dataSet = null;

                dataSet = MySqlDBHelper.ExecuteDataSet(MySqlDBHelper.Conn, CommandType.Text, strSql);

                if (dataSet != null && dataSet.Tables[0].Rows.Count > 0)
                {
                    ProductionMDL mdl = ProductionMDL.ParseDataRow(dataSet.Tables[0].Rows[0]);
                    unit     = new CTUnitMDL();
                    unit.PN  = mdl.PN;
                    unit.CT  = mdl.CT;
                    unit.EMS = mdl.EMS;
                    unit.OP  = mdl.OP;

                    return(unit);
                }
                else
                {
                    return(null);
                }
            }
            catch
            {
                return(null);
            }
        }
示例#6
0
        public ProductionMDL GetProductInfo(string lineID, int ems)
        {
            ProductionMDL mdl = null;

            try
            {
                string strSql = string.Empty;

                int nline = 0;
                Int32.TryParse(lineID, out nline);

                if (nline <= 0)
                {
                    return(null);
                }


                strSql = "select * from tlb_product where PLID='{0}' and EMS='{1}'";

                strSql = string.Format(strSql, nline.ToString(), ems);


                DataSet dataSet = MySqlDBHelper.ExecuteDataSet(MySqlDBHelper.Conn, CommandType.Text, strSql);

                if (dataSet == null || dataSet.Tables.Count <= 0)
                {
                    return(null);
                }

                //解析数据
                mdl = ProductionMDL.ParseDataRow(dataSet.Tables[0].Rows[0]);

                return(mdl);
            }
            catch
            {
                throw;
            }
        }
示例#7
0
        /// <summary>
        /// 更新产品信息
        /// </summary>
        /// <param name="info"></param>
        public int UpdateProduction(ProductionMDL mdl)
        {
            int ret = 0;

            string strSql = string.Empty;

            try
            {
                strSql = "UPDATE tlb_product SET NAME='{0}',PN='{1}',CODE='{2}',TYPE={3},FACTORY='{4}',CT={5},OP={6},REMARK='{7}' WHERE EMS={8} AND PLID={9}";

                strSql = string.Format(strSql, mdl.Name, mdl.PN, mdl.Code, mdl.CodeType, mdl.Factory, mdl.CT, mdl.OP, mdl.Remark, mdl.EMS, mdl.PLID);

                ret = MySqlDBHelper.ExecuteNonQuery(MySqlDBHelper.Conn, CommandType.Text, strSql, null);

                return(ret);
            }
            catch (Exception ex)
            {
                CLog.WriteErrLogInTrace(ex.Message);
                return(0);
            }
        }
示例#8
0
        /// <summary>
        /// 更新产品信息
        /// </summary>
        /// <param name="info"></param>
        public int UpdateProduction(ProductionMDL mdl)
        {
            int ret = 0;

            string strSql = string.Empty;

            try
            {
                //DateTime theDate = DateTime.Now;
                //theDate.ToString("yyyy-MM-dd HH:mm:ss");
                string dateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                strSql = "update production set lineid='{0}',brakename='{1}',brakeid='{2}',brakecode='{3}',factory='{4}',remark='{5}' where tid='{6}'";
                //   strSql = string.Format(strSql, mdl.LineNum, mdl.ProductName, mdl.ProductID, mdl.ProductCode, mdl.Factory, mdl.Remark, mdl.TID);

                //  ret = MySqlDBHelper.ExecuteNonQuery(MySqlDBHelper.Conn, CommandType.Text, strSql,null);
                ret = SQLiteDBHelper.ExecuteNonQuery(strSql);
                return(ret);
            }
            catch (Exception ex)
            {
                CLog.WriteErrLogInTrace(ex.Message);
                return(0);
            }
        }
示例#9
0
        /// <summary>
        /// 更新采集单元数据
        /// </summary>
        /// <param name="mdl"></param>
        /// <param name="curUnit"></param>
        /// <returns></returns>
        public int  UpdateAcqUnitData(ref AcqLineItemMDL mdl)
        {
            int ret = -1;

            try
            {
                AcqLineDAL acqDal = new AcqLineDAL();

                ProductDal pdal = new ProductDal();


                //获取PN编码
                //
                ProductionMDL productmdl = pdal.GetProductInfo(mdl.PLID, mdl.EMS);


                //存在产品编码
                if (mdl == null || mdl.PN == string.Empty)
                {
                    mdl.PN = "N/A";
                }

                mdl.PN = productmdl.PN;

                ////判断是存在有历史数据,有更新区间信息
                ////有历史数据

                if (acqDal.AcqUintExist2(mdl.PLID, mdl.EMS, mdl.UNITID) > 0)
                {
                    //获取当前区间的计数
                    //int percount = GetLastRangCount(mdl);

                    AcqLineItemMDL lastItem = GetLastUnit(mdl);
                    //加一个脉冲信号
                    lastItem.PR_COUNT += 1;
                    //加一个脉冲信号

                    CLog.WriteStationLog("PRE_COUNT", mdl.UNITID + "-" + lastItem.PR_COUNT.ToString());

                    //更新结束时间 和 当前开始时段的时间信息
                    mdl.TID        = lastItem.TID;
                    mdl.TGNAME     = lastItem.TGNAME;
                    mdl.PR_COUNT   = lastItem.PR_COUNT;
                    mdl.START_TIME = lastItem.START_TIME;
                    mdl.END_TIME   = DateTime.Now;

                    mdl.TIME_LENGTH = TimeRange.ExecDateDiffSecond(lastItem.START_TIME, mdl.END_TIME);

                    mdl.UPDATE_TIME = mdl.END_TIME;

                    ret = acqDal.UpdateAcqLineUint(mdl);
                }
                else///当前时段的新项目
                {
                    int uintSeq = acqDal.IsUionAcqUint(mdl.UNITID, mdl.PLID);

                    mdl.START_TIME = DateTime.Now;
                    mdl.END_TIME   = mdl.START_TIME;

                    //型号发生变化重新计数 同时表示换型了
                    if (uintSeq > 0)
                    {
                        uintSeq += 1;

                        string strSeq = String.Format("{0:D2}", uintSeq);
                        mdl.SetTID(mdl.START_TIME, mdl.PLID, mdl.TGNAME, strSeq);
                    }

                    // mdl.UPDATE_TIME = DateTime.Now;


                    if (productmdl != null || productmdl.OP != 0)
                    {
                        mdl.START_TIME = DateTime.Now.AddSeconds(-productmdl.OP);
                    }
                    else
                    {
                        mdl.START_TIME = DateTime.Now;
                    }

                    mdl.TIME_LENGTH = TimeRange.ExecDateDiffSecond(mdl.START_TIME, mdl.END_TIME);

                    //更新上一个区间产品的时间
                    AcqLineDAL updateDal = new AcqLineDAL();
                    updateDal.UpdateAclineUnitByLastUnit(DateTime.Now, mdl.PLID);


                    // modify by guozq  2018/3/26
                    //添加采集数据
                    ret = acqDal.AddAcqLine1(mdl);
                }
            }
            catch
            {
                throw;
            }

            return(ret);
        }
示例#10
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            this.dataGridView1.CellValueChanged -= new DataGridViewCellEventHandler(dataGridView1_CellContentClick);

            DataRow rd = null;

            switch (e.ColumnIndex)
            {
            case 5:


                ProductionInfo addInfoForm = new ProductionInfo();
                addInfoForm.IsUpdate = true;
                rd = this.infos.Rows[e.RowIndex];

                ProductionMDL info = new ProductionMDL();
                info.Load(rd);

                addInfoForm.Production = info;
                if (addInfoForm.ShowDialog() == DialogResult.OK)
                {
                    ProductDal dal = new ProductDal();
                    if (dal.UpdateProduction(info) > 0)
                    {
                        this.LoadDataGridView();
                        MessageBox.Show("修改产品信息成功!");
                    }
                    else
                    {
                        MessageBox.Show("修改产品信息失败!");
                    }
                }


                break;

            case 6:


                if (MessageBox.Show("确定要删除该产品信息吗?", "系统提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK)
                {
                    rd = this.infos.Rows[e.RowIndex];

                    int id = Convert.ToInt32(rd["tid"]);

                    ProductDal dal = new ProductDal();

                    if (dal.DeleteProduction(id) > 0)
                    {
                        this.LoadDataGridView();
                    }
                    else
                    {
                        MessageBox.Show("删除产品信息失败!");
                    }
                }



                break;

            default:
                break;
            }


            this.dataGridView1.CellValueChanged += new DataGridViewCellEventHandler(dataGridView1_CellContentClick);
        }
示例#11
0
        private void btConvert_Click(object sender, EventArgs e)
        {
            if (this.txtPath.Text == null || this.txtPath.Text == String.Empty)
            {
                MessageBox.Show("请填选择导入文件", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            try
            {
                string selectFile = this.txtPath.Text.Trim();


                if (selectFile == null || selectFile == string.Empty)
                {
                    MessageBox.Show("未获导入数据信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }



                //if (openFileDialog.ShowDialog() == DialogResult.Yes)
                //{
                //    csvTable = CSVFileHelper.OpenCSV(selectFile);
                //}
                //else
                //{
                //    this.txtPath.Text = String.Empty;
                //    this.lbContent.Text = String.Empty;
                //}

                DataTable csvTable = null;


                csvTable = CSVFileHelper.OpenCSV(selectFile);


                if (csvTable == null || csvTable.Rows.Count <= 1)
                {
                    MessageBox.Show("未获导入数据信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (csvTable.Columns == null)
                {
                    MessageBox.Show("未获导入正确数据信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (csvTable.Columns.Count != 5)
                {
                    MessageBox.Show("未获导入正确数据信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (csvTable.Columns[0].ColumnName != "PN")
                {
                    MessageBox.Show("未获导入正确数据信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }



                if (MessageBox.Show("请确保产线为非生产状态,确定更新请选择‘是’", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                {
                    return;
                }

                ProductDal dal = new ProductDal();

                int countAdd = 0;
                int countRef = 0;


                int count = csvTable.Rows.Count;

                double div = (double)count / 100;

                double pogressValue = 0;

                foreach (DataRow row in csvTable.Rows)
                {
                    ProductionMDL mdl = new ProductionMDL();

                    mdl = ProductionMDL.ParseDataRow(row);

                    int ret = -1;

                    pogressValue += div;

                    if (dal.IsExist(mdl.PN) > 0)
                    {
                        ret = dal.UpdateProduction(mdl);

                        if (ret > 0)
                        {
                            countRef++;
                            UpdateContentInfo(mdl.PN + "更新成功", (int)div);
                        }
                        else
                        {
                            UpdateContentInfo(mdl.PN + "更新失败", (int)div);
                        }
                    }
                    else
                    {
                        ret = dal.InsertProduction(mdl);

                        if (ret > 0)
                        {
                            countAdd++;
                            UpdateContentInfo(mdl.PN + "入库成功", (int)div);
                        }
                        else
                        {
                            UpdateContentInfo(mdl.PN + "入库失败", (int)div);
                        }
                    }
                }

                //    UpdateContentInfo((countAdd+countRef).ToString() + "记录入库成功!");

                MessageBox.Show((countAdd + countRef).ToString() + "记录入库成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }