/// <summary> /// 添加新角色信息 /// 创建:李东峰 日期:2014-03-11 /// </summary> /// <param name="rName">角色名称</param> /// <returns>返回是否添加成功</returns> public bool AddRole(string rName) { errMsg = ""; bool _flag = false; string sql1 = "select * from T_SYS_GROUP where T_GRPID='" + RoleId + "'"; DataTable dt = null; dt = dl.RunDataTable(sql1, out errMsg); if (dt == null || dt.Rows.Count == 0) { string sql2 = "insert into T_SYS_GROUP (T_GRPID,T_GRPDESC) values ('" + RoleId + "','" + rName + "')"; dl.RunNonQuery(sql2, out errMsg); if (errMsg == "") { _flag = true; } else { _flag = false; } } else { _flag = false; } return(_flag); }
/// <summary> /// 添加新班次信息 /// 创建:李东峰 日期:2014-03-13 /// </summary> /// <param name="_shiftName">班次名称</param> /// <param name="_startTime">班次名称</param> /// <param name="_endTime">班次名称</param> /// <returns>返回是否添加成功</returns> public bool AddShift(string _shiftName, string _startTime, string _endTime) { errMsg = ""; bool _flag = false; string sql1 = "select * from T_SYS_SHIFTINFO where T_SHIFTID='" + ShfitId + "'"; DataTable dt = null; dt = dl.RunDataTable(sql1, out errMsg); if (dt == null || dt.Rows.Count == 0) { string sql2 = "insert into T_SYS_SHIFTINFO (T_SHIFTID,T_SHIFTNAME,D_STRATTIME,D_ENDTIME) values ('" + ShfitId + "','" + _shiftName + "','2014-01-01 " + _startTime + "','2014-01-01 " + _endTime + "')"; dl.RunNonQuery(sql2, out errMsg); if (errMsg == "") { _flag = true; } else { _flag = false; } } else { _flag = false; } return(_flag); }
/// <summary> /// 添加新班组信息 /// 创建:李东峰 日期:2014-03-12 /// </summary> /// <param name="rName">班组名称</param> /// <returns>返回是否添加成功</returns> public bool AddClass(string _ClassName) { errMsg = ""; bool _flag = false; string sql1 = "select * from T_SYS_CLASSINFO where T_CLASSID='" + ClassId + "'"; DataTable dt = null; dt = dl.RunDataTable(sql1, out errMsg); if (dt == null || dt.Rows.Count == 0) { string sql2 = "insert into T_SYS_CLASSINFO (T_CLASSID,T_CLASSNAME) values ('" + ClassId + "','" + _ClassName + "')"; dl.RunNonQuery(sql2, out errMsg); if (errMsg == "") { _flag = true; } else { _flag = false; } } else { _flag = false; } return(_flag); }
/// <summary> /// 设置平均负荷 /// </summary> /// <param name="unitId">机组编号</param> /// <param name="val">负荷</param> /// <param name="sTime">开始时间</param> /// <param name="eTime">结束时间</param> /// <returns></returns> public double SetPowerAvg(string unitId, double val, string sTime, string eTime) { sql = "update T_INFO_STATISCS set T_VALUE='" + val + "' where T_UNITID='" + unitId + "' and (T_TIME between '" + sTime + "' and '" + eTime + "')"; judge = db.RunNonQuery(sql, out errMsg); if (judge) { val = 1000000; } return(val); }
/// <summary> /// 为数据库表添加列 /// </summary> /// <param name="tableName">数据库表名称</param> /// <param name="columns">列集合</param> /// <returns></returns> public bool CreateColumns(string tableName, string columns) { judge = true; for (int i = 0; i < columns.Split('*').Length; i++) { sql += "IF COL_LENGTH('" + tableName + "', '" + columns.Split('*')[i] + "') IS NULL alter table " + tableName + " add " + columns.Split('*')[i] + " char(255);"; } judge = dl.RunNonQuery(sql, out errMsg); return(judge); }
//提交按钮对应函数 protected void BtnSubmit_Click(object sender, EventArgs e) { int rowsCount = (this.Request.Form.Count - 3) / 8; StringBuilder msg = new StringBuilder(); //确保统计时间不为空 for (int i = 0; i < rowsCount; ++i) { if (Request.Form.Get(colNames[1] + (i == 0 ? "" : i.ToString())) == "") { msg.AppendFormat("统计时间不能为空 \\nline:{0}", i); Response.Write("<script> alert(\"" + msg.ToString() + "\")</script>"); return; } } for (int i = 0; i < rowsCount; ++i) { foreach (string col in colNames) { hashtRow[col] = Request.Form.Get(col + (i == 0 ? "" : i.ToString())); } dl.RunNonQuery(string.Format("insert into {0} {1}", tableName, GetPartInsertSql()), out errMsg); //ExecuteSql(string.Format("insert into EDITPARA {0}", GetPartInsertSql())); } return; }
/// <summary> /// 为数据库表添加列 /// </summary> /// <param name="tableName">数据库表名称</param> /// <param name="columns">列集合</param> /// <returns></returns> public bool CreateColumns(string tableName, string columns) { judge = true; //if (rlDBType == "SQL") //{ for (int i = 0; i < columns.Split('*').Length; i++) { sql += "IF COL_LENGTH('" + tableName + "', '" + columns.Split('*')[i] + "') IS NULL alter table " + tableName + " add " + columns.Split('*')[i] + " char(255);"; } judge = db.RunNonQuery(sql, out errMsg); //} //else if (rlDBType == "Oracle") //{ // for (int i = 0; i < columns.Split('*').Length; i++) // { // sql = "SELECT COUNT(*) FROM USER_TAB_COLUMNS WHERE TABLE_NAME = UPPER('" + tableName + "') AND COLUMN_NAME = '" + columns.Split('*')[i] + "'"; // dt = SAC.OracleHelper.OracleHelper.Query(sql).Tables[0]; // if (dt.Rows[0][0].ToString() == "0") // { // sql = "alter table " + tableName + " add(" + columns.Split('*')[i] + " varchar(255) default '')"; // judge = SAC.OracleHelper.OracleHelper.RunNonQuery(sql, out errMsg); // } // } //} return(judge); }
/// <summary> /// 添加报表名称 /// </summary> /// <param name="name"></param> /// <returns></returns> public bool AddTable(string name, string id, string model, string tableName) { sql = "insert into " + tableName + "(T_REPORTDESC,T_DCNAME,T_MODELID) values('" + name + "','" + id + "','" + model + "')"; judge = dl.RunNonQuery(sql, out errMsg); sql = ""; return(judge); }
//保存新的角色信息 public bool SaveRole(string rId, string rName, out string errMsg) { errMsg = ""; bool flag = false; string sql1 = "select * from Administrator.T_SYS_GROUP where T_GRPID='" + rId + "'"; DataTable dt = null; dt = dl.RunDataTable(sql1, out errMsg); if (dt == null || dt.Rows.Count == 0) { string sql2 = "insert into Administrator.T_SYS_GROUP (T_GRPID,T_GRPDESC) values ('" + rId + "','" + rName + "')"; dl.RunNonQuery(sql2, out errMsg); if (errMsg == "") { return(true); } else { return(false); } } else { return(false); } }
/// <summary> /// 添加人员 /// 创建:李东峰 日期:2014-03-10 /// </summary> /// <param name="_userName">用户真实姓名</param> /// <param name="_passWord">用户密码</param> /// <param name="_attachMent">用户照片</param> /// <param name="_classId">用户班组</param> /// <param name="_posId">用户岗位</param> /// <param name="_posId">用户所属角色ID</param> /// <returns>返回是否添加成功</returns> public bool AddMember(string _userName, string _passWord, byte[] _attachMent, string _classId, string _posId, string _grpId) { string rlDBType = dl.init(); string _errMsg; string sql1 = ""; string sql2 = ""; bool result = false; if (rlDBType == "SQL") { if (_attachMent != null && _attachMent.Length > 0) { sql1 = "insert into T_SYS_MEMBERINFO(T_USERID,T_USERNAME,T_PASSWD,B_ATTACHMENT,T_CLASSID,T_POSID) values(@T_USERID,@T_USERNAME,@T_PASSWD,@B_ATTACHMENT,@T_CLASSID,@T_POSID);"; } else { sql1 = "insert into T_SYS_MEMBERINFO(T_USERID,T_USERNAME,T_PASSWD,T_CLASSID,T_POSID) values(@T_USERID,@T_USERNAME,@T_PASSWD,@T_CLASSID,@T_POSID);"; } sql2 = "insert into T_SYS_MEMBERGRP(T_USERID,T_GRPID) values('" + UserId + "','" + _grpId + "')"; try { SqlConnection sqlconn = SAC.DBOperations.DBsql.GetConnection(); SqlCommand sqlcmd = new SqlCommand(sql1, sqlconn); if (_attachMent != null && _attachMent.Length > 0) { sqlcmd.Parameters.Add("@T_USERID", UserId); sqlcmd.Parameters.Add("@T_USERNAME", _userName); sqlcmd.Parameters.Add("@T_PASSWD", _passWord); sqlcmd.Parameters.Add("@B_ATTACHMENT", _attachMent); sqlcmd.Parameters.Add("@T_PASSWD", _classId); sqlcmd.Parameters.Add("@T_POSID", _posId); } else { sqlcmd.Parameters.Add("@T_USERID", UserId); sqlcmd.Parameters.Add("@T_USERNAME", _userName); sqlcmd.Parameters.Add("@T_PASSWD", _passWord); sqlcmd.Parameters.Add("@T_PASSWD", _classId); sqlcmd.Parameters.Add("@T_POSID", _posId); } if (sqlcmd.ExecuteNonQuery() > 0) { result = true; } sqlconn.Close(); dl.RunNonQuery(sql2, out _errMsg); } catch (Exception ex) { LogHelper.WriteLog(LogHelper.EnLogType.Run, "发生时间:" + DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + "/n错误信息:" + ex.Message); result = false; } } else if (rlDBType == "DB2") { if (_attachMent != null && _attachMent.Length > 0) { sql1 = "insert into T_SYS_MEMBERINFO(T_USERID,T_USERNAME,T_PASSWD,B_ATTACHMENT,T_CLASSIS,T_POSID) values(?,?,?,?,?,?);"; } else { sql1 = "insert into T_SYS_MEMBERINFO(T_USERID,T_USERNAME,T_PASSWD,T_CLASSIS,T_POSID) values(?,?,?,?,?);"; } sql2 = "insert into T_SYS_MEMBERGRP(T_USERID,T_GRPID) values('" + UserId + "','" + _grpId + "')"; try { OleDbConnection con = new OleDbConnection(SAC.DBOperations.DBdb2.SetConString()); con.Open(); OleDbCommand oledbcom = new OleDbCommand(sql1, con); if (_attachMent != null && _attachMent.Length > 0) { oledbcom.Parameters.Add("?", UserId); oledbcom.Parameters.Add("?", _userName); oledbcom.Parameters.Add("?", _passWord); oledbcom.Parameters.Add("?", _attachMent); oledbcom.Parameters.Add("?", _classId); oledbcom.Parameters.Add("?", _posId); } else { oledbcom.Parameters.Add("?", UserId); oledbcom.Parameters.Add("?", _userName); oledbcom.Parameters.Add("?", _passWord); oledbcom.Parameters.Add("?", _classId); oledbcom.Parameters.Add("?", _posId); } if (oledbcom.ExecuteNonQuery() > 0) { result = true; } con.Close(); dl.RunNonQuery(sql2, out _errMsg); } catch (Exception ex) { LogHelper.WriteLog(LogHelper.EnLogType.Run, "发生时间:" + DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + "/n错误信息:" + ex.Message); result = false; } } else if (rlDBType == "ORACLE") { if (_attachMent != null && _attachMent.Length > 0) { sql1 = "insert into T_SYS_MEMBERINFO(T_USERID,T_USERNAME,T_PASSWD,B_ATTACHMENT,T_CLASSIS,T_POSID) values(:blobtodb,:blobtodb,:blobtodb,:blobtodb,:blobtodb,:blobtodb);"; } else { sql1 = "insert into T_SYS_MEMBERINFO(T_USERID,T_USERNAME,T_PASSWD,T_CLASSIS,T_POSID) values(:blobtodb,:blobtodb,:blobtodb,:blobtodb,:blobtodb);"; } sql2 = "insert into T_SYS_MEMBERGRP(T_USERID,T_GRPID) values('" + UserId + "','" + _grpId + "')"; try { OracleConnection con = new OracleConnection(SAC.DBOperations.OracleHelper.retStr()); con.Open(); OracleCommand oledbcom = new OracleCommand(sql1, con); if (_attachMent != null && _attachMent.Length > 0) { oledbcom.Parameters.Add("blobtodb", UserId); oledbcom.Parameters.Add("blobtodb", _userName); oledbcom.Parameters.Add("blobtodb", _passWord); oledbcom.Parameters.Add("blobtodb", _attachMent); oledbcom.Parameters.Add("blobtodb", _classId); oledbcom.Parameters.Add("blobtodb", _posId); } else { oledbcom.Parameters.Add("blobtodb", UserId); oledbcom.Parameters.Add("blobtodb", _userName); oledbcom.Parameters.Add("blobtodb", _passWord); oledbcom.Parameters.Add("blobtodb", _classId); oledbcom.Parameters.Add("blobtodb", _posId); } if (oledbcom.ExecuteNonQuery() > 0) { result = true; } con.Close(); dl.RunNonQuery(sql2, out _errMsg); } catch (Exception ex) { LogHelper.WriteLog(LogHelper.EnLogType.Run, "发生时间:" + DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + "/n错误信息:" + ex.Message); result = false; } } return(result); }