Exemple #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool UpdateEx(Maticsoft.Model.BST.staff_data model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update staff_data set ");
            strSql.Append("name=@name,");
            //strSql.Append("info=@info,");
            //strSql.Append("image=@image,");
            //strSql.Append("authority=@authority,");
            strSql.Append("date_begin=@date_begin,");
            strSql.Append("date_end=@date_end,");
            strSql.Append("data_keepon1=@data_keepon1,");
            strSql.Append("data_keepon2=@data_keepon2,");
            strSql.Append("data_keepon3=@data_keepon3,");
            strSql.Append("data_keepon4=@data_keepon4,");
            strSql.Append("data_keepon5=@data_keepon5");
            strSql.Append(" where id=@id ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@name",         MySqlDbType.VarChar, 45),
                //new MySqlParameter("@info", MySqlDbType.VarBinary),
                //new MySqlParameter("@image", MySqlDbType.MediumBlob),
                //new MySqlParameter("@authority", MySqlDbType.VarChar,1),
                new MySqlParameter("@date_begin",   MySqlDbType.VarChar, 45),
                new MySqlParameter("@date_end",     MySqlDbType.VarChar, 45),
                new MySqlParameter("@data_keepon1", MySqlDbType.VarChar, 45),
                new MySqlParameter("@data_keepon2", MySqlDbType.VarChar, 45),
                new MySqlParameter("@data_keepon3", MySqlDbType.VarChar, 45),
                new MySqlParameter("@data_keepon4", MySqlDbType.VarChar, 45),
                new MySqlParameter("@data_keepon5", MySqlDbType.VarChar, 45),
                new MySqlParameter("@id",           MySqlDbType.VarChar, 60)
            };
            parameters[0].Value = model.name;
            //parameters[1].Value = model.info;
            //parameters[2].Value = model.image;
            //parameters[3].Value = model.authority;
            parameters[1].Value = model.date_begin;
            parameters[2].Value = model.date_end;
            parameters[3].Value = model.data_keepon1;
            parameters[4].Value = model.data_keepon2;
            parameters[5].Value = model.data_keepon3;
            parameters[6].Value = model.data_keepon4;
            parameters[7].Value = model.data_keepon5;
            parameters[8].Value = model.id;

            int rows = DbHelperMySQLP.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
        public bool DeleteAll(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("delete from staff_data ");
            if (!string.IsNullOrWhiteSpace(strWhere))
            {
                strSql.Append("where " + strWhere);
            }
            int rows = DbHelperMySQLP.ExecuteSql(strSql.ToString());

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #3
0
        public static string SetRolesEmail(GSSModel.SendEmailToRole email)
        {
            //读取MySQL匹配的连接串[此处返回错误码]
            string linkName   = string.Format("LKSV_GSS_3_gsdata_db_{0}_{1}", email.BigZoneId, email.ZoneId);
            string error      = string.Empty;
            string connString = QueryMysqlLinkConnString(linkName, ref error);

            if (!string.IsNullOrEmpty(error))
            {
                return(error);
            }
            string filter = FilterDBConnString(connString);

            //查询目前数据库中最大的ID
            DbHelperMySQLP.connectionString = filter;
            //DbHelperMySQLP db = new DbHelperMySQLP(connString);
            string queryIdCmd = "select MAX(mail_id) from maillist_table";

            DbHelperMySQL.connectionString = filter;
            DataSet           ds   = DbHelperMySQL.Query(queryIdCmd);
            DataRowCollection rows = ds.Tables[0].Rows;
            //此处不考虑连接失败的情况
            long id = 1;

            if (rows.Count > 0)
            {
                object obj = rows[0][0];
                string mid = obj == null ? string.Empty : obj.ToString();
                if (!string.IsNullOrEmpty(mid))//该列数据存储不是为null
                {
                    id = long.Parse(mid);
                }
            }
            string[]    rids  = email.ReceiveRoles.Split(',');
            List <byte> item1 = new List <byte>();

            if (email.EquipNum > 0)
            {
                item1.AddRange(BitConverter.GetBytes(email.EquipNum));
                item1.AddRange(BitConverter.GetBytes(email.EquipId));
            }
            StringBuilder sbs = new StringBuilder();

            foreach (byte item in item1)
            {
                string i = item.ToString("X2");
                sbs.Append(i);
            }
            for (int i = 0; i < rids.Length; i++)
            {                                                                  //MySQL 此处提供参数不能使用【底层代码需要进行确认】
                List <byte> checkdata = new List <byte>();
                checkdata.AddRange(BitConverter.GetBytes(0));                  //第一项4字节int
                checkdata.AddRange(BitConverter.GetBytes((byte)0));            //第二项byte
                checkdata.AddRange(BitConverter.GetBytes(0));                  //第三项4字节int
                checkdata.AddRange(BitConverter.GetBytes(int.Parse(rids[i]))); //第四项2字节word
                checkdata.AddRange(BitConverter.GetBytes(0));                  //第五项4字节int
                checkdata.AddRange(BitConverter.GetBytes((byte)3));            //第六项?? mailtype
                checkdata.AddRange(BitConverter.GetBytes((short)0));           //第七项 已读状态 byte[wstate]
                checkdata.AddRange(BitConverter.GetBytes((byte)0));            //第八项 byte
                checkdata.AddRange(BitConverter.GetBytes(0));                  //第九项 byte
                StringBuilder checkDataStr = new StringBuilder();
                foreach (byte item in checkdata)
                {
                    string cd = item.ToString("X2");
                    checkDataStr.Append(cd);
                }
                string cmd = @"insert into maillist_table(Mail_ID,Mail_Title,Mail_Content,Mail_TYPE,Receiver_ID,Sender_ID,Sender_Name,Send_Time,Invalid_Time,State_Modi_Time,Item_Num,item1,checkData)  
                values (" + (id + i + 1) + ",'" + email.Head + "','" + email.Body + "',3," + rids[i] + ",-1,'GSSClient','" + email.StartTime + "','" + email.EndTime + "','"
                             + DateTime.Now + "'," + email.EquipNum + ",{0},0x{1})";
                string equip = sbs.ToString();
                if (string.IsNullOrEmpty(equip))
                {
                    equip = "null";
                }
                else
                {
                    equip = "0x" + equip;
                }
                cmd = string.Format(cmd, equip, checkDataStr.ToString());
                try
                {
                    DbHelperMySQLP.connectionString = filter;
                    int result = DbHelperMySQLP.ExecuteSql(cmd);
                }
                catch (Exception ex)
                {
                    return(ex.Message);
                }
            }
            return(string.Empty);
        }