示例#1
0
        public List <PlinePlanMDL> GetPlanInfos(DateTime datetime)
        {
            List <PlinePlanMDL> list = null;

            try
            {
                DataSet dataSet = null;

                string strSql = "SELECT * FROM tlb_product_plan WHERE PLANID LIKE '{0}%'";

                strSql = string.Format(strSql, datetime.ToString("yyyyMMdd"));


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

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

                list = new List <PlinePlanMDL>();

                foreach (DataRow row in dataSet.Tables[0].Rows)
                {
                    list.Add(PlinePlanMDL.PraseDataRow(row));
                }


                return(list);
            }
            catch
            {
                throw;
            }
        }
示例#2
0
        /// <summary>
        /// 添加采集数据单元
        /// </summary>
        /// <param name="mdl"></param>
        /// <returns></returns>
        public int AddPlinePlan(PlinePlanMDL mdl)
        {
            int ret = 0;

            string strSql = string.Empty;


            try
            {
                strSql = "INSERT INTO  tlb_product_plan ( PLANID,PLINE,NAME,OP1,OP1_T,OP1_BEGIN,OP1_RANGE,OP1_ITEMS,OP2,OP2_T,OP2_BEGIN,OP2_RANGE,OP2_ITEMS,CREATE_TIME,REMARK)" +
                         " VALUES ('{0}','{1}','{2}',{3},{4},'{5}',{6},'{7}',{8},{9},'{10}',{11},'{12}','{13}','{14}')";
                //"values('{0}','{1}','{2}',{3},{4},'{5}',{6},{7},{8},'{9}',{10},'{11}','{12}')";

                strSql = string.Format(strSql, mdl.PLANID, mdl.PLINE, mdl.NAME, mdl.OP1, mdl.OP1_T, mdl.OP1_BEGIN.ToString("yyyy-MM-dd HH:mm:ss"),
                                       mdl.OP1_RANGE, OPMDL.BuildOPString(mdl.OP1_ITEMS), mdl.OP2, mdl.OP2_T, mdl.OP2_BEGIN.ToString("yyyy-MM-dd HH:mm:ss"),
                                       mdl.OP2_RANGE, OPMDL.BuildOPString(mdl.OP2_ITEMS), mdl.CREATE_TIME.ToString("yyyy-MM-dd HH:mm:ss"), mdl.REMARK);

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

                return(ret);
            }
            catch
            {
                throw;
            }
        }
示例#3
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;
            }
        }
示例#4
0
        /// <summary>
        /// 获取记录
        /// </summary>
        /// <param name="lineID"></param>
        /// <param name="range"></param>
        /// <returns>minutes</returns>
        public PlinePlanMDL GetPlanInfo(string lineID)
        {
            PlinePlanMDL mdl = null;

            try
            {
                DataSet dataSet = null;

                string strSql = "SELECT * FROM tlb_product_plan WHERE PLANID='{0}'";

                strSql = string.Format(strSql, lineID);


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

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

                mdl = PlinePlanMDL.PraseDataRow(dataSet.Tables[0].Rows[0]);

                return(mdl);
            }
            catch
            {
                throw;
            }
        }
示例#5
0
        public DataTable GetProductTable(string lineID)
        {
            try
            {
                DataSet dataSet = null;

                string strSql = "SELECT * FROM tlb_product WHERE PLID='{0}' ORDER BY CREATE_TIME ASC";
                strSql = string.Format(strSql, lineID);


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

                if (dataSet != null)
                {
                    return(dataSet.Tables[0]);
                }

                return(null);
            }
            catch (Exception ex)
            {
                CLog.WriteErrLogInTrace(ex.Message);
                return(null);
            }
        }
示例#6
0
        public DataTable GetProductPage(int startOffset, int endOffset, string lineID)
        {
            try
            {
                DataSet dataSet = null;


                //string strSql = "SELECT tp.PLID,tp.CODE,tp.PN,tp.EMS,tp.CT,tp.OP FROM tlb_product tp  WHERE tp.PLID='{0}' ORDER BY CREATE_TIME ASC  LIMIT {1},{2};";
                string strSql = "SELECT tp.PLID,tp.CODE,tp.PN,tp.EMS,tp.CT,tp.OP FROM tlb_product tp  WHERE tp.PLID='{0}' ORDER BY EMS ASC  LIMIT {1},{2};";

                strSql = string.Format(strSql, lineID, startOffset, endOffset);

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

                if (dataSet == null)
                {
                    return(null);
                }

                return(dataSet.Tables[0]);
            }
            catch (Exception ex)
            {
                CLog.WriteErrLogInTrace(ex.Message);
                return(null);
            }
        }
示例#7
0
        /// <summary>
        /// 插入单项产品计划
        /// </summary>
        /// <param name="mdl"></param>
        /// <returns></returns>
        public int InsertProductionPlanItem(ProductionPlanMDL mdl)
        {
            int ret = 0;

            string strSql = string.Empty;

            try
            {
                strSql = "insert into  production_plan (plan_id,pline_id,station_id,start_time,end_time,brakeid,plan_num,actual_num,shift,create_time,remark)" +
                         "values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}')";

                strSql = string.Format(strSql, mdl.PlanID, mdl.Pline_ID, mdl.Station_ID, mdl.StartTime.ToString("yyyy-MM-dd HH:mm:ss"),
                                       mdl.EndTime.ToString("yyyy-MM-dd HH:mm:ss"), mdl.BreakeID, mdl.PlanNum,
                                       mdl.Actual_num, mdl.Shift, mdl.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), mdl.Remark);

                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>
        /// <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);
            }
        }
示例#9
0
        /// <summary>
        /// 获取产品计划通过产品ID和时间
        /// </summary>
        /// <param name="planid"></param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <returns></returns>
        public DataTable GetProductionPalnByDateTime(string planid, DateTime startTime, DateTime endTime)
        {
            try
            {
                DataSet dataSet = null;

                string strSql = "select * from production_plan where plan_id='{0}' and create_time between '{1}' and '{2}'  order by start_time desc";

                strSql = string.Format(strSql, planid, startTime.ToString("yyyy-MM-dd HH:mm:ss"), endTime.ToString("yyyy-MM-dd HH:mm:ss"));


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

                if (dataSet != null)
                {
                    return(dataSet.Tables[0]);
                }

                return(null);
            }
            catch (Exception ex)
            {
                CLog.WriteErrLogInTrace(ex.Message);
                return(null);
            }
        }
示例#10
0
        public string GetTIDByDataTime(string planid, DateTime startTime, DateTime endTime)
        {
            try
            {
                object nvalue = null;

                string ret = string.Empty;

                string strSql = "select tid from production_plan where plan_id='{0}' and start_time = '{1}' and end_time ='{2}'";
                string sDate  = String.Format("{0:yyyy-MM-dd HH:mm:ss}", startTime); //4-10-2010 17:16:50\
                string eDate  = String.Format("{0:yyyy-MM-dd HH:mm:ss}", endTime);
                strSql = string.Format(strSql, planid, sDate, eDate);


                nvalue = MySqlDBHelper.ExecuteScalar(MySqlDBHelper.Conn, CommandType.Text, strSql);

                if (nvalue == null)
                {
                    return(string.Empty);
                }

                ret = Convert.ToInt32(nvalue).ToString();

                return(ret);
            }
            catch (Exception ex)
            {
                CLog.WriteErrLogInTrace(ex.Message);
                return(string.Empty);
            }
        }
示例#11
0
        /// <summary>
        /// 通过计划ID获取产线计划
        /// </summary>
        /// <param name="planid"></param>
        /// <returns></returns>
        public DataTable GetProductionPalnByPlanID2(string planid)
        {
            try
            {
                DataSet dataSet = null;

                string strSql = "select * from production_plan where planid='{0}' ";

                strSql = string.Format(strSql, planid);


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

                if (dataSet != null)
                {
                    return(dataSet.Tables[0]);
                }

                return(null);
            }
            catch (Exception ex)
            {
                CLog.WriteErrLogInTrace(ex.Message);
                return(null);
            }
        }
示例#12
0
        /// <summary>
        /// 获取产品计划通过序号ID
        /// </summary>
        /// <param name="planid"></param>
        /// <returns></returns>
        public ProductionPlanMDL GetProductionPalnByID(int tid)
        {
            try
            {
                ProductionPlanMDL mdl = new ProductionPlanMDL();


                DataSet dataSet = null;

                string strSql = "select * from production_plan where tid='{0}' ";

                strSql = string.Format(strSql, tid);


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


                if (dataSet != null)
                {
                    DataRow row = dataSet.Tables[0].Rows[0];

                    mdl.Prase(row);

                    return(mdl);
                }
                return(null);
            }
            catch (Exception ex)
            {
                CLog.WriteErrLogInTrace(ex.Message);
                return(null);
            }
        }
示例#13
0
        public bool ExistParam(string lineid, string productid, string stationID)
        {
            bool    flag   = false;
            string  format = string.Empty;
            DataSet set    = null;

            try
            {
                format = "select count(*) as num from process_parameter where lineid='{0}' and productid='{1}' and substring(processs,1,5)='{2}'";
                format = string.Format(format, lineid, productid, stationID.Substring(0, 5));
                set    = MySqlDBHelper.ExecuteDataSet(MySqlDBHelper.Conn, CommandType.Text, format, null);
                if ((set.Tables[0].Rows.Count > 0) && (set.Tables[0].Rows[0]["num"].ToString() != "0"))
                {
                    flag = true;
                }
            }
            catch (Exception exception)
            {
                CLog.WriteErrLogInTrace(exception.Message);
            }
            finally
            {
                if (set != null)
                {
                    set.Dispose();
                }
            }
            return(flag);
        }
示例#14
0
        public PrintCountMDL GetDataByKeyName(string keyName)
        {
            string        format = string.Empty;
            PrintCountMDL tmdl   = null;
            DataSet       set    = null;

            try
            {
                format = "select tid, keyname, keycount, updatetime, remark from print_count where keyname='{0}'";
                format = string.Format(format, keyName);
                set    = MySqlDBHelper.ExecuteDataSet(MySqlDBHelper.Conn, CommandType.Text, format, null);
                if (set.Tables[0].Rows.Count > 0)
                {
                    tmdl             = new PrintCountMDL();
                    tmdl.TID         = Convert.ToInt32(set.Tables[0].Rows[0]["tid"]);
                    tmdl.KeyName     = keyName;
                    tmdl.KeyCount    = Convert.ToInt32(set.Tables[0].Rows[0]["keycount"]);
                    tmdl.UpdapteTime = Convert.ToDateTime(set.Tables[0].Rows[0]["updatetime"]);
                    tmdl.Remark      = set.Tables[0].Rows[0]["remark"].ToString();
                }
            }
            catch (Exception exception)
            {
                tmdl = null;
                CLog.WriteErrLogInTrace(exception.Message);
            }
            finally
            {
                if (set != null)
                {
                    set.Dispose();
                }
            }
            return(tmdl);
        }
示例#15
0
        /// <summary>
        /// 更新产线计划
        /// </summary>
        /// <param name="mdl"></param>
        /// <returns></returns>
        public int UpdatePlinePlan(PlinePlanMDL mdl)
        {
            int ret = 0;

            string strSql = string.Empty;


            try
            {
                strSql = "UPDATE  tlb_product_plan SET PLINE='{0}' ,NAME='{1}',OP1={2},OP1_T={3},OP1_BEGIN='{4}',OP1_RANGE={5},OP1_ITEMS='{6}',OP2={7},"
                         + "OP2_T={8},OP2_BEGIN='{9}',OP2_RANGE={10},OP2_ITEMS='{11}',REMARK='{12}' WHERE PLANID='{13}'";

                strSql = string.Format(strSql, mdl.PLINE, mdl.NAME, mdl.OP1, mdl.OP1_T, mdl.OP1_BEGIN.ToString("yyyy-MM-dd HH:mm:ss"),
                                       mdl.OP1_RANGE, OPMDL.BuildOPString(mdl.OP1_ITEMS), mdl.OP2, mdl.OP2_T, mdl.OP2_BEGIN.ToString("yyyy-MM-dd HH:mm:ss"),
                                       mdl.OP2_RANGE, OPMDL.BuildOPString(mdl.OP2_ITEMS), mdl.REMARK, mdl.PLANID);

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

                return(ret);
            }
            catch
            {
                throw;
            }
        }
示例#16
0
        public int GetChangeTimeByUnit(string lineID, string unitid)
        {
            int ct = 0;

            try
            {
                DataSet dataSet = null;

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

                strSql = string.Format(strSql, lineID, unitid);


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

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

                ///获取换型时间秒为单位
                foreach (DataRow row in dataSet.Tables[0].Rows)
                {
                    ct += ChangeTimeMDL.ParseDataRow(row).TIME_MIG;
                }

                return(ct);
            }
            catch
            {
                throw;
            }
        }
示例#17
0
        /// <summary>
        /// 添加采集数据单元
        /// </summary>
        /// <param name="mdl"></param>
        /// <returns></returns>
        public int AddExTimeItem(ExtTimeMDL mdl)
        {
            int ret = 0;

            string strSql = string.Empty;


            try
            {
                strSql = "insert into  tlb_ext_time ( PLINEID,NAME,LUNCH,L_TIME,DINNER,D_TIME,REMARK)" +
                         "values('{0}','{1}','{2}',{3},'{4}',{5},'{6}')";

                strSql = string.Format(strSql, mdl.PLINEID, mdl.NAME, mdl.LUNCH.ToString("yyyy-MM-dd HH:mm:ss"),
                                       mdl.L_TIME, mdl.DINNER.ToString("yyyy-MM-dd HH:mm:ss"),
                                       mdl.D_TIME, mdl.REMARK);

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

                return(ret);
            }
            catch
            {
                throw;
            }
        }
示例#18
0
        public List <ExtTimeMDL> GetExtimes()
        {
            List <ExtTimeMDL> list = null;

            try
            {
                DataSet dataSet = null;

                string strSql = "SELECT * FROM tlb_ext_time ";


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

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


                list = new List <ExtTimeMDL>();

                foreach (DataRow row in dataSet.Tables[0].Rows)
                {
                    list.Add(ExtTimeMDL.PraseDataRow(row));
                }

                return(list);
            }
            catch
            {
                throw;
            }
        }
示例#19
0
        /// <summary>
        ///
        /// 获取广报版信息
        /// </summary>
        /// <returns></returns>
        public string GetNoticeInfo()
        {
            string ret = string.Empty;

            object obj = null;


            try
            {
                string strSql = "select content from notice order by update_time";

                obj = MySqlDBHelper.ExecuteScalar(MySqlDBHelper.Conn, CommandType.Text, strSql);

                if (obj != null)
                {
                    ret = Convert.ToString(obj);
                }

                return(ret);
            }
            catch (Exception ex)
            {
                CLog.WriteErrLogInTrace(ex.Message);
                return(string.Empty);
            }
        }
示例#20
0
        /// <summary>
        /// 插入文本文本内容
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        private int InsertNoticeInfo(string info)
        {
            int ret = 0;

            string strSql = string.Empty;

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

                strSql = "insert into  notice (tid,content,update_time) values(1,'{0}','{1}')";

                strSql = string.Format(strSql, info, theDate);

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

                return(ret);
            }
            catch (Exception ex)
            {
                CLog.WriteErrLogInTrace(ex.Message);
                return(0);
            }
        }
示例#21
0
        public int GetPassCondition(string stationID, string lineID)
        {
            string  format = string.Empty;
            int     num    = 0;
            DataSet set    = null;

            try
            {
                format = "select passcondition from device_list where devicetype='串口' and stationid='{0}' and lineid='{1}'";
                format = string.Format(format, stationID, lineID);
                set    = MySqlDBHelper.ExecuteDataSet(MySqlDBHelper.Conn, CommandType.Text, format, null);
                if ((set.Tables[0].Rows.Count > 0) && (set.Tables[0].Rows[0]["passcondition"].ToString() != string.Empty))
                {
                    num = Convert.ToInt32(set.Tables[0].Rows[0]["passcondition"]);
                }
            }
            catch (Exception exception)
            {
                CLog.WriteErrLogInTrace(exception.Message);
            }
            finally
            {
                if (set != null)
                {
                    set.Dispose();
                }
            }
            return(num);
        }
示例#22
0
        public int UpdateByField(string fieldName, string fieldValue, int valueType, string keyName, string keyValue)
        {
            int    num    = 0;
            string format = string.Empty;

            try
            {
                if (valueType == 2)
                {
                    format = "update device_list set {0}='{1}' where {2}='{3}'";
                }
                else if (valueType == 1)
                {
                    format = "update device_list set {0}={1} where {2}='{3}'";
                }
                format = string.Format(format, new object[] { fieldName, fieldValue, keyName, keyValue });
                num    = MySqlDBHelper.ExecuteNonQuery(MySqlDBHelper.Conn, CommandType.Text, format, null);
                if (num <= 0)
                {
                    CLog.WriteErrLog(format);
                }
                return(num);
            }
            catch (Exception exception)
            {
                CLog.WriteErrLogInTrace(exception.Message);
                CLog.WriteErrLog(format);
                return(0);
            }
        }
示例#23
0
        public bool UpdateProductNameByKeyCode(string keyFieldName, string barCode, string productType)
        {
            object obj2   = null;
            string format = string.Empty;
            string str2   = string.Empty;
            bool   flag   = false;

            try
            {
                format = "select productname from process_parameter where productid='{0}' limit 1";
                format = string.Format(format, productType);
                obj2   = MySqlDBHelper.ExecuteScalar(MySqlDBHelper.Conn, CommandType.Text, format, null);
                if (obj2 != null)
                {
                    str2 = obj2.ToString();
                }
                format = "update result_line2 set productname='{0}' where {1}='{2}'";
                format = string.Format(format, str2, keyFieldName, barCode);
                if (MySqlDBHelper.ExecuteNonQuery(MySqlDBHelper.Conn, CommandType.Text, format, null) > 0)
                {
                    flag = true;
                }
            }
            catch (Exception exception)
            {
                CLog.WriteErrLogInTrace(exception.Message);
                flag = false;
            }
            return(flag);
        }
示例#24
0
        public int UpdateByField(string fieldName, object fieldValue, string keyName, string keyValue)
        {
            string format = string.Empty;

            try
            {
                Type type = fieldValue.GetType();
                if (type == typeof(string))
                {
                    format = "update result_line2 set {0}='{1}',updatetime = now() where {2}='{3}'";
                }
                else
                {
                    if ((((type != typeof(int)) && (type != typeof(double))) && (type != typeof(float))) && (type != typeof(bool)))
                    {
                        throw new Exception("fieldValue的值只能为string、bool、int、double或float类型");
                    }
                    format = "update result_line2 set {0}={1},updatetime = now() where {2}='{3}'";
                }
                format = string.Format(format, new object[] { fieldName, fieldValue, keyName, keyValue });
                return(MySqlDBHelper.ExecuteNonQuery(MySqlDBHelper.Conn, CommandType.Text, format, null));
            }
            catch (Exception exception)
            {
                CLog.WriteErrLogInTrace(exception.Message);
                return(0);
            }
        }
示例#25
0
        /// <summary>
        /// 获取产线设置的空闲时间
        /// </summary>
        /// <param name="pline"></param>
        /// <param name="claOrder"></param>
        /// <param name="rangid"></param>
        /// <param name="rang"></param>
        /// <returns></returns>
        public List <TimeRange> GetTimeRangeByRange(string pline, int claOrder, string rangid, TimeRange rang)
        {
            List <TimeRange> rets = new List <TimeRange>();

            try
            {
                DataSet dataSet = null;



                pline = Convert.ToInt32(pline).ToString();

                // string strSql = "SELECT * FROM tlb_line_dt dt WHERE dt.START_TIME>='{0}' AND dt.END_TIME<='{1}' AND dt.PLINEID='{2}' AND dt.CLA_ORDER={3} AND dt.RANGEID='{4}' ORDER BY dt.START_TIME ASC";

                string strSql = "SELECT * FROM tlb_line_dt dt WHERE  dt.PLINEID='{0}' AND dt.CLA_ORDER={1} AND dt.RANGEID='{2}' ORDER BY dt.START_TIME ASC";

                //strSql = string.Format(strSql, rang.StartTime.ToString("yyyy-MM-dd HH:mm:ss"), rang.EndTime.ToString("yyyy-MM-dd HH:mm:ss"), pline, claOrder, rangid);

                strSql = string.Format(strSql, pline, claOrder, rangid);

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

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

                int count = 0;

                foreach (DataRow row in dataSet.Tables[0].Rows)
                {
                    PlineDTMDL mdl = PlineDTMDL.ParseDataRow(row);

                    string tempDate = String.Format("{0}-{1:D2}-{2:D2} {3:D2}:{4:D2}:{5:D2}",
                                                    DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day
                                                    , mdl.START_TIME.Hour, mdl.START_TIME.Minute, mdl.START_TIME.Second);

                    DateTime StartTime = Convert.ToDateTime(tempDate);
                    tempDate = string.Empty;

                    tempDate = String.Format("{0}-{1:D2}-{2:D2} {3:D2}:{4:D2}:{5:D2}",
                                             DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day
                                             , mdl.END_TIME.Hour, mdl.END_TIME.Minute, mdl.END_TIME.Second);

                    DateTime EndTime = Convert.ToDateTime(tempDate);

                    TimeRange rangItem = new TimeRange(StartTime, EndTime);

                    rets.Add(rangItem);
                }

                return(rets);
            }
            catch
            {
                throw;
            }
        }
示例#26
0
        public int MoveBrakeDataToCaliper(string brakeCode, string caliperCode)
        {
            int     num11;
            int     num    = 0;
            int     num9   = 0;
            int     num10  = 0;
            string  format = string.Empty;
            DataSet set    = new DataSet();

            MySqlParameter[] commandParameters = null;
            try
            {
                format = "select tid,st300,st320,st332,st350,st360,st361,st290,trialproduce from result_line2 where (length(calipercode)<=0 or calipercode is null) and brakecode='{0}' order by updatetime desc limit 1";
                format = string.Format(format, brakeCode);
                set    = MySqlDBHelper.ExecuteDataSet(MySqlDBHelper.Conn, CommandType.Text, format, null);
                if (set.Tables[0].Rows.Count <= 0)
                {
                    return(0);
                }
                num = Convert.ToInt32(set.Tables[0].Rows[0]["tid"]);
                if (set.Tables[0].Rows[0]["trialproduce"].ToString() != string.Empty)
                {
                    num9 = Convert.ToInt32(set.Tables[0].Rows[0]["trialproduce"]);
                }
                commandParameters = new MySqlParameter[] { new MySqlParameter("@brakecode", brakeCode), new MySqlParameter("@st300", set.Tables[0].Rows[0]["st300"]), new MySqlParameter("@st320", set.Tables[0].Rows[0]["st320"]), new MySqlParameter("@st332", set.Tables[0].Rows[0]["st332"]), new MySqlParameter("@st350", set.Tables[0].Rows[0]["st350"]), new MySqlParameter("@st360", set.Tables[0].Rows[0]["st360"]), new MySqlParameter("@st361", set.Tables[0].Rows[0]["st361"]), new MySqlParameter("@st290", set.Tables[0].Rows[0]["st290"]), new MySqlParameter("@calipercode", caliperCode) };
                if (num9 == 1)
                {
                    format = "update result_line2 set brakecode=@brakecode,st300=@st300,st320=@st320,st332=@st332,st350=@st350,st360=@st360,st361=@st361,st290=@st290,trialproduce=1,updatetime = now() where calipercode=@calipercode";
                }
                else
                {
                    format = "update result_line2 set brakecode=@brakecode,st300=@st300,st320=@st320,st332=@st332,st350=@st350,st360=@st360,st361=@st361,st290=@st290,updatetime = now() where calipercode=@calipercode";
                }
                num10 = MySqlDBHelper.ExecuteNonQuery(MySqlDBHelper.Conn, CommandType.Text, format, commandParameters);
                if (num10 > 0)
                {
                    format = "delete from result_line2 where tid={0}";
                    format = string.Format(format, num);
                }
                num11 = num10;
            }
            catch (Exception exception)
            {
                CLog.WriteErrLogInTrace(exception.Message);
                num11 = 0;
            }
            finally
            {
                set.Dispose();
            }
            return(num11);
        }
示例#27
0
        public bool CheckStationResult(string keyFieldName, string barCode, string productType, string stationID, List <PLCDataMDL> testItemList)
        {
            bool    flag    = true;
            string  cmdText = string.Empty;
            DataSet set     = new DataSet();

            try
            {
                cmdText = cmdText + "select ";
                foreach (PLCDataMDL amdl in testItemList)
                {
                    cmdText = cmdText + amdl.DBFieldName;
                    cmdText = cmdText + ",";
                }
                if (testItemList.Count > 0)
                {
                    cmdText = cmdText.Substring(0, cmdText.Length - 1);
                }
                else
                {
                    return(false);
                }
                cmdText = string.Format(cmdText + " from result_line2 where {0}='{1}' order by updatetime desc limit 1", keyFieldName, barCode);
                set     = MySqlDBHelper.ExecuteDataSet(MySqlDBHelper.Conn, CommandType.Text, cmdText, null);
                if (set.Tables[0].Rows.Count <= 0)
                {
                    return(false);
                }
                for (int i = 0; i < set.Tables[0].Columns.Count; i++)
                {
                    string columnName = set.Tables[0].Columns[i].ColumnName;
                    if (set.Tables[0].Rows[0][columnName].ToString() == string.Empty)
                    {
                        return(false);
                    }
                }
                return(flag);
            }
            catch (Exception exception)
            {
                CLog.WriteErrLogInTrace(exception.Message);
                flag = false;
            }
            finally
            {
                if (set != null)
                {
                    set.Dispose();
                }
            }
            return(flag);
        }
示例#28
0
        public DataTable GetDeviceList(string lineID)
        {
            string format = string.Empty;

            try
            {
                format = "select tid,deviceid,devicestate,remark from device_list where (devicetype='PLC' or devicetype='TCP/IP') and lineid='{0}'";
                format = string.Format(format, lineID);
                return(MySqlDBHelper.ExecuteDataSet(MySqlDBHelper.Conn, CommandType.Text, format, null).Tables[0]);
            }
            catch (Exception exception)
            {
                CLog.WriteErrLogInTrace(exception.Message);
                return(null);
            }
        }
示例#29
0
        public int UpdateResultByKeyCode(string keyFieldName, string barCode, int integrity, int valid, int result, string resultDesc)
        {
            string format = string.Empty;

            try
            {
                format = "update result_line2 set integrity={0},valid={1},result={2},resultdesc='{3}' where {4}='{5}'";
                format = string.Format(format, new object[] { integrity, valid, result, resultDesc, keyFieldName, barCode });
                return(MySqlDBHelper.ExecuteNonQuery(MySqlDBHelper.Conn, CommandType.Text, format, null));
            }
            catch (Exception exception)
            {
                CLog.WriteErrLogInTrace(exception.Message);
                return(0);
            }
        }
示例#30
0
        public int InsertCode(string codeName, string codeValue)
        {
            string format = string.Empty;

            try
            {
                format = "insert into result_line2({0},createtime) values ('{1}',now())";
                format = string.Format(format, codeName, codeValue);
                return(MySqlDBHelper.ExecuteNonQuery(MySqlDBHelper.Conn, CommandType.Text, format, null));
            }
            catch (Exception exception)
            {
                CLog.WriteErrLogInTrace(exception.Message);
                return(0);
            }
        }