Ejemplo n.º 1
0
        public bool panDuanChongQiByUpdate(string pcname, string[] pcnames)
        {
            SqlHelp sqh = SqlHelp.GetInstance();

            lock (obj)
            {
                try
                {
                    int r = 0;
                    for (int i = 0; i < pcnames.Length; i++)
                    {
                        if (pcname.ToUpper().Equals(pcnames[i].ToUpper()))
                        {
                            r = i;
                        }
                    }
                    int       r1     = 0;
                    string    sqlsel = "select xh,pcxiugai from jiankong where xh in( select max(xh) zd from jiankong)";
                    DataTable dt     = sqh.getAll(sqlsel);
                    if (dt.Rows.Count > 0)
                    {
                        string   quan   = (string)dt.Rows[0][1];
                        string[] quanzu = quan.Split('|');
                        r1 = int.Parse(quanzu[r]);
                        WriteLog.WriteLogFile("r1:" + r1);
                    }
                    int r2 = -1;
                    sqlsel = "select xh,pcxiugai from jiankong where xh in( select max(xh)-1 zd from jiankong)";
                    dt     = sqh.getAll(sqlsel);
                    if (dt.Rows.Count > 0)
                    {
                        string   quan   = (string)dt.Rows[0][1];
                        string[] quanzu = quan.Split('|');
                        r2 = int.Parse(quanzu[r]);
                        WriteLog.WriteLogFile("r2:" + r2);
                    }
                    if (r1 == r2)
                    {
                        return(true);
                    }
                    return(false);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Ejemplo n.º 2
0
        public DateTime getYunXingQkLasttime()
        {
            SqlHelp sqh = SqlHelp.GetInstance();

            lock (obj)
            {
                try
                {
                    DataTable dt = sqh.getAll("select max(gxsj) from yunxingqk ");
                    if (dt.Rows.Count > 0)
                    {
                        return((DateTime)dt.Rows[0][0]);
                    }
                    return(DateTime.MaxValue);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Ejemplo n.º 3
0
 /*
  * USE [yiquan]
  * GO
  *  SET ANSI_NULLS ON
  *  GO
  *  SET QUOTED_IDENTIFIER ON
  *  GO
  *  SET ANSI_PADDING ON
  *  GO
  *  CREATE TABLE [dbo].[zhanghao](
  *  [name] [varchar](50) NULL,
  *  [pwd] [varchar](50) NULL,
  *  [yxbz] [char](1) NULL,
  *  [dengluzhong] [char](1) NULL,
  *  [dqindex] [int] NULL,
  *  [pcname] [varchar](50) NULL,
  *  [img] [varchar](50) NULL,
  *  [imgtime] [date] NULL,
  *  [daydenglu] [text] NULL,
  *  [yimai] [char](1) NULL
  *  ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
  *
  *  GO
  *
  *  SET ANSI_PADDING OFF
  *  GO
  */
 /// <summary>
 /// 单例模式====双层互锁
 /// </summary>
 /// <returns></returns>
 public static SqlHelp GetInstance()
 {
     if (mysql == null)
     {
         lock (obj)
         {
             mysql = new SqlHelp();
             string connString = null;
             if (MyFuncUtil.getMachineName().ToLower().Equals("wlzhongkong") || MyFuncUtil.getMachineName().ToLower().Equals("wlbgs"))
             {
                 connString = "Data Source=" + MyFuncUtil.getMachineName().ToLower() + @"\SQLEXPRESS;Initial Catalog=yiquan;User ID=sa;Password=123456";
             }
             else
             {
                 connString = @"Data Source=192.168.4.44;Initial Catalog=yiquan;User ID=sa;Password=123456";
             }
             conn = new SqlConnection(connString);
         }
     }
     return(mysql);
 }
Ejemplo n.º 4
0
        public void gxYunXingQk1(string youxi)
        {
            //得到运行情况后存入表
            WriteLog.WriteLogFile("得到运行情况后存入表");
            SqlHelp sqh = SqlHelp.GetInstance();

            lock (obj)
            {
                try
                {
                    YunXingQK jqqk   = new YunXingQK();
                    string    selsql = "select " +
                                       "sum(case when  z.pcname='1hao' and z.xgsj>=convert(varchar(10),getdate(),120) then 1 else 0 end)  hao1chanshu," +
                                       "sum(case when  z.pcname='2hao' and z.xgsj>=convert(varchar(10),getdate(),120) then 1 else 0 end)  hao2xiugai," +
                                       "sum(case when  z.pcname='2hao' and z.zuanshi>0 and z.xgsj>=convert(varchar(10),getdate(),120) then 1 else 0 end)  hao2chanshu," +
                                       "sum(case when  z.pcname='3hao' and z.xgsj>=convert(varchar(10),getdate(),120) then 1 else 0 end)  hao3xiugai," +
                                       "sum(case when  z.pcname='3hao' and z.zuanshi>0 and z.xgsj>=convert(varchar(10),getdate(),120) then 1 else 0 end)  hao2chanshu," +
                                       "sum(case when  z.pcname='wlzhongkong' and z.xgsj>=convert(varchar(10),getdate(),120) then 1 else 0 end)  zkxiugai," +
                                       "sum(case when  z.pcname='wlzhongkong' and z.zuanshi>0 and z.xgsj>=convert(varchar(10),getdate(),120) then 1 else 0 end)  zkchanshu," +
                                       "sum(case when z.zuanshi>0  then 1 else 0 end)  zuanshidayu0," +
                                       "sum(case when z.zuanshi>1000  then 1 else 0 end)  zuanshidayu1000," +
                                       "sum(case when z.zuanshi>3000  then 1 else 0 end)  zuanshidayu3000," +
                                       "sum(case when z.qiangzhequan>0  then 1 else 0 end)  qiangzhedayu0," +
                                       "sum(case when z.xgsj>=convert(varchar(10),getdate(),120) then 1 else 0 end)  zxiugai" +
                                       " from zhanghao z ";
                    //where youxi='" + youxi + "'";

                    DataTable dt = sqh.getAll(selsql);
                    int       a  = dt.Rows.Count;
                    if (dt.Rows.Count > 0)
                    {
                        Dictionary <string, JiQiYunXing> dict = new Dictionary <string, JiQiYunXing>();
                        JiQiYunXing jq1 = new JiQiYunXing();
                        jq1.Chuchan = (int)dt.Rows[0][0];
                        dict.Add("hao1", jq1);
                        JiQiYunXing jq2 = new JiQiYunXing();
                        jq2.Xiugai  = (int)dt.Rows[0][1];
                        jq2.Chuchan = (int)dt.Rows[0][2];
                        dict.Add("hao2", jq2);
                        JiQiYunXing jq3 = new JiQiYunXing();
                        jq3.Xiugai  = (int)dt.Rows[0][3];
                        jq3.Chuchan = (int)dt.Rows[0][4];
                        dict.Add("hao3", jq3);
                        JiQiYunXing zk = new JiQiYunXing();
                        zk.Xiugai  = (int)dt.Rows[0][5];
                        zk.Chuchan = (int)dt.Rows[0][6];
                        dict.Add("zk", zk);
                        jqqk.Jqyx            = dict;
                        jqqk.Zuanshidayu0    = (int)dt.Rows[0][7];
                        jqqk.Zuanshidayu1000 = (int)dt.Rows[0][8];
                        jqqk.Zuanshidayu3000 = (int)dt.Rows[0][9];
                        jqqk.Qiangzhedayu0   = (int)dt.Rows[0][10];
                        jqqk.Xgsj            = DateTime.Now;
                        jqqk.Zongxiugai      = (int)dt.Rows[0][11];
                        WriteLog.WriteLogFile("当前运行机器的出产情况" + jqqk.Zongxiugai + "单独:" + jqqk.Jqyx["hao1"].Chuchan + " " + jqqk.Jqyx["hao2"].Chuchan + "  " + jqqk.Jqyx["hao3"].Chuchan + " " + jqqk.Jqyx["zk"].Chuchan);
                    }
                    string inssql = "insert into yunxingqk (hao1chanchu,hao2xiugai,hao2chanchu,hao3xiugai,hao3chanchu,zkxiugai,zkchanchu,zuanshidayu0,zuanshidayu1000,zuanshidayu3000,qiangzhedayu0,gxsj,zxiugai) values("
                                    + jqqk.Jqyx["hao1"].Chuchan + "," + jqqk.Jqyx["hao2"].Xiugai + "," + jqqk.Jqyx["hao2"].Chuchan
                                    + "," + jqqk.Jqyx["hao3"].Xiugai + "," + jqqk.Jqyx["hao3"].Chuchan
                                    + "," + jqqk.Jqyx["zk"].Xiugai + "," + jqqk.Jqyx["zk"].Chuchan
                                    + "," + jqqk.Zuanshidayu0 + "," + jqqk.Zuanshidayu1000
                                    + "," + jqqk.Zuanshidayu3000 + "," + jqqk.Qiangzhedayu0 + ",'" + jqqk.Xgsj + "'," + jqqk.Zongxiugai + ")";
                    sqh.update(inssql);
                }
                catch (Exception ex)
                {
                    WriteLog.WriteLogFile("更新运行情况失败");
                    throw ex;
                }
            }
        }