public ArticleViewRule(string ConnetionString) { ConnStr = ConnetionString; db = new MDataBase(ConnStr); }
//查询方法 private void selectBindData() { //拼SQL前半截 string sql = "select Exam_Id,ExamName,ScoreType,BeginTime,EndTime,CreatedBy,(case ScoreType when '0' then '当时评分' else '1' end) as contidion from SExmExam"; //拼SQL后半截 string con = ""; if (txtExamId.Text.Trim() != "") { con = con + " and Exam_Id like '%" + txtExamId.Text + "%'"; } if (txtExamName.Text.Trim() != "") { con = con + " and ExamName like '%" + txtExamName.Text + "%'"; } if (sltQuestionTypeName.Text != "") { con = con + " and ScoreType='" + sltQuestionTypeName.SelectedValue + "'"; } if (txtCreatedBy.Text != "") { con = con + " and CreatedBy like '%" + txtCreatedBy.Text + "%'"; } if (con != "") { //截断第1个and con = con.Substring(con.IndexOf("and") + 4); //拼成完整SQL sql = sql + " where " + con; } //代入数据库查询 DataTable dt = new DataTable(); db = new MDataBase(config.DBConn); db.GetDataTable(sql, out dt); //如果查询结果为空 if (dt.Rows.Count == 0) { //隐藏控件 btnFirstPage.Visible = false; btnForwardPage.Visible = false; btnNextPage.Visible = false; btnLastPage.Visible = false; this.lblCount.Visible = false; lblPage.ForeColor = Color.Red; lblPage.Text = "对不起,没有查询到相关信息!"; gvExam.Visible = false; btnChange.Visible = false; btnDelete.Visible = false; this.lblCountPage.Visible = false; } else { //重新显示控件 this.lblCount.Visible = true; this.lblCountPage.Visible = true; btnFirstPage.Visible = true; btnForwardPage.Visible = true; btnNextPage.Visible = true; btnLastPage.Visible = true; gvExam.Visible = true; btnChange.Visible = true; btnDelete.Visible = true; gvExam.PageSize = 20; gvExam.DataSource = dt; gvExam.DataBind(); //显示搜索到的全部条数 this.lblCount.Text = "共有" + (dt.Rows.Count).ToString() + "条记录"; //显示GridView的页数 lblPage.ForeColor = Color.Black; lblPage.Text = "/共" + (gvExam.PageCount).ToString() + "页"; //显示GV是第几页 lblCountPage.Text = "第" + (gvExam.PageIndex + 1).ToString() + "页"; //GV中的radiobutton默认选定第一条 RadioButton rbtn = ((RadioButton)(gvExam.Rows[0].Cells[0].FindControl("jrbSelect"))); rbtn.Checked = true; } //如果查询条件全都为空 if (con == "") { BindDataGv(); } }
/// <summary> /// SExmScore对象Insert方法 /// </summary> private bool executeInsert() { bool blnFirstField = true; string sql = "insert into SExmScore("; string sqlTmp = " values("; // (Score_Guid)字段 if (_blnScore_GuidChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "Score_Guid"; sqlTmp += "'" + _Score_Guid + "'"; } // (Exam_Id)字段 if (_blnExam_IdChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "Exam_Id"; sqlTmp += "'" + _Exam_Id + "'"; } // (Staff_Id)字段 if (_blnStaff_IdChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "Staff_Id"; sqlTmp += "'" + _Staff_Id + "'"; } // (StartTime)字段 if (_blnStartTimeChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "StartTime"; sqlTmp += "'" + _StartTime.ToString() + "'"; } // (EndTime)字段 if (_blnEndTimeChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "EndTime"; sqlTmp += "'" + _EndTime.ToString() + "'"; } // (RightCount)字段 if (_blnRightCountChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "RightCount"; sqlTmp += _RightCount.ToString(); } // (WrongCount)字段 if (_blnWrongCountChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "WrongCount"; sqlTmp += _WrongCount.ToString(); } // (UnfinishCount)字段 if (_blnUnfinishCountChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "UnfinishCount"; sqlTmp += _UnfinishCount.ToString(); } // (Score)字段 if (_blnScoreChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "Score"; sqlTmp += _Score.ToString(); } // (Gradation)字段 if (_blnGradationChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "Gradation"; sqlTmp += _Gradation.ToString(); } sql += ")" + sqlTmp + ")"; try { MDataBase db = new MDataBase(_DBConn); db.executeInsert(sql); return(true); } catch (Exception err) { throw; return(false); } }
/// <summary> /// SSysStaffProjectRole对象GetInfo方法 /// </summary> private bool executeGetInfo() { bool blnFirstField = true; string sql = "select * from SSysStaffProjectRole"; // (Staff_Id)字段 if (_blnStaff_IdChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "Staff_Id = '" + _Staff_Id + "'"; } // (Project_Id)字段 if (_blnProject_IdChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "Project_Id = '" + _Project_Id + "'"; } // (Role_Id)字段 if (_blnRole_IdChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "Role_Id = '" + _Role_Id + "'"; } // (IsDefault)字段 if (_blnIsDefaultChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "IsDefault = " + _IsDefault.ToString(); } try { MDataBase db = new MDataBase(_DBConn); DataRow dr; bool blnReturnCode = db.GetDataRow(sql, out dr); if (blnReturnCode == false || dr == null) { return(false); } // 对属性赋值 try { _Staff_Id = dr["Staff_Id"].ToString(); } catch (Exception err) { } try { _Project_Id = dr["Project_Id"].ToString(); } catch (Exception err) { } try { _Role_Id = dr["Role_Id"].ToString(); } catch (Exception err) { } try { _IsDefault = Convert.ToInt32(dr["IsDefault"]); } catch (Exception err) { } return(true); } catch (Exception err) { throw; return(false); } }
public KnowledgeRule(string ConnetionString) { //ConnStr = ConnetionString; db = new MDataBase(ConnetionString); GetInformation = new GetInformation(ConnetionString); }
/// <summary> /// 取4小时内的预约任务 /// </summary> private static void GetRespeakTaskFromDB() { try { DateTime Now = DateTime.Now.AddHours(Convert.ToDouble(RespeakTime)); string sql = "SELECT A.Task_Guid, A.Customer_Guid, B.ItemName, A.Staff_Id, A.StartTime FROM SDrmTasks A LEFT OUTER JOIN SDrmItems B ON A.Item_Id = B.Item_Id WHERE A.StartTime is not null and A.StartTime<='" + Now.ToString("yyyy-MM-dd HH:mm:ss") + "' and A.Lock is null and A.Finish_Id is null and (B.BeginTime <= GETDATE()) AND (B.EndTime >= GETDATE()) AND (B.TaskLocation = 0) AND (B.WorkStatusId = 0) AND (B.StatusId = 0) order by A.StartTime"; MDataBase db = new MDataBase(config.DBConn); _RespeakTaskPool = new Hashtable(); db.Open(); DataTable dt; bool blnReturnCode = db.GetDataTable(sql, out dt); if (blnReturnCode == true) { //foreach (DataRow dr in dt.Rows) //{ // Hashtable ht; // if (_RespeakTaskPool.ContainsKey(dr["Staff_Id"].ToString()) == true) // { // ht = (Hashtable)_RespeakTaskPool[dr["Staff_Id"].ToString()]; // ht.Add(dr["StartTime"].ToString(), dr); // } // else // { // ht = new Hashtable(); // ht.Add(dr["StartTime"].ToString(), dr); // _RespeakTaskPool.Add(dr["Staff_Id"].ToString(), ht); // } //} foreach (DataRow dr in dt.Rows) { Hashtable ht; if (_RespeakTaskPool.ContainsKey(dr["Staff_Id"].ToString()) == true) { ht = (Hashtable)_RespeakTaskPool[dr["Staff_Id"].ToString()]; bool blnOnce = false; DateTime StartTime = Convert.ToDateTime(dr["StartTime"]); while (blnOnce == false) { if (ht.ContainsKey(StartTime) == true) { StartTime = StartTime.AddSeconds(1); } else { ht.Add(StartTime, dr); blnOnce = true; } } } else { ht = new Hashtable(); ht.Add(dr["StartTime"].ToString(), dr); _RespeakTaskPool.Add(dr["Staff_Id"].ToString(), ht); } } } db.Close(); _RespeakLastRefresh = DateTime.Now; } catch (Exception err) { //string tmp = err.Message; ErrorLog.LogInsert(err.Message, "App_Code/OBTask", ""); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ////////////////// CSSysStaff staff = new CSSysStaff(); config.Staff = staff; staff.Staff_Id = "00000001"; ////////////////// //判断权限 string strPower = Function.CheckStaff(config); //得到所有员工姓名、部门、是否在线等信息 db = new MDataBase(config.DBConn); DataTable dt = new DataTable(); string sql = "select a.Staff_Id,a.Name,b.Name AS Department,a.IsMonitor,LastLoginTime - LastLogoutTime AS IsOnline,a.Dept_Id From SSysStaff a Left Join SSysdepartment b on a.Dept_Id = b.Dept_Id Where a.StatusId=0 ORDER BY b.Name,a.IsMonitor DESC"; db.GetDataTable(sql, out dt); TableRow tr1; TableCell tcJob; ////插入第一行 //tr1 = new TableRow(); //tcJob = new TableCell(); //tcJob.Text = "局长"; //tcJob.HorizontalAlign = HorizontalAlign.Right; //tcJob.Width = 50; //tr1.Cells.Add(tcJob); //tlbIsOnline.Rows.Add(tr1); ////插入局长名字及在线状态 //tr1 = new TableRow(); //tcJob = new TableCell(); //tcJob.Text = " "; //tcJob.Width = 50; //tr1.Cells.Add(tcJob); //tcJob = new TableCell(); //tcJob.Text = "***" + " ●"; ////根据条件判断应该经什么颜色显示 //tcJob.ForeColor = Color.Red; //tcJob.Width = 50; //tr1.Cells.Add(tcJob); //tlbIsOnline.Rows.Add(tr1); ////插入第三行 //tr1 = new TableRow(); //tcJob = new TableCell(); //tcJob.Text = "副局长"; //tcJob.HorizontalAlign = HorizontalAlign.Right; //tcJob.Width = 50; //tr1.Cells.Add(tcJob); //tlbIsOnline.Rows.Add(tr1); //插入副局长的名字 //插入各部门 //得到各个部门 db = new MDataBase(config.DBConn); DataTable dtDept = new DataTable(); string strDeptSql = "select b.Name AS Department,b.Dept_Id As DeptId,MIN(b.OrderIndex) AS [Index] From SSysStaff a Left Join SSysdepartment b on a.Dept_Id = b.Dept_Id Where a.StatusId=0 And b.Name!='' Group by b.Name,b.Dept_Id Order by [Index]"; db.GetDataTable(strDeptSql, out dtDept); for (int i = 0; i < dtDept.Rows.Count; i++) { //添加部门行 tr1 = new TableRow(); tcJob = new TableCell(); tcJob.ColumnSpan = 2; CheckBox cbf = new CheckBox(); cbf.Text = dtDept.Rows[i][0].ToString(); cbf.ID = dtDept.Rows[i][1].ToString(); tcJob.Controls.Add(cbf); //判断权限确定能够选择哪些员工 if (strPower == "Yes") { cbf.Enabled = true; } else if (strPower == dtDept.Rows[i][1].ToString()) { cbf.Enabled = true; } else { cbf.Enabled = false; } cbf.InputAttributes.Add("onclick", "AllSelect('tlb" + cbf.ID + "');"); //tcJob.Text = dtDept.Rows[i][0].ToString(); tcJob.HorizontalAlign = HorizontalAlign.Left; tcJob.Width = 50; tr1.Cells.Add(tcJob); tlbIsOnline.Rows.Add(tr1); //添加部门人员行 //得到相应部门的员工 DataRow[] dr = dt.Select("Department='" + dtDept.Rows[i][0].ToString() + "'", "IsMonitor"); if (dr.Length > 0) { tr1 = new TableRow(); tr1.Width = 600; TableCell tcBlank = new TableCell(); tcBlank.Width = 50; tr1.Cells.Add(tcBlank); TableCell tc1 = new TableCell(); tc1.Width = 600; //新建个表,存放员工信息 Table tab = new Table(); tab.ID = "tlb" + dtDept.Rows[i][1].ToString(); //创建新表的行 TableRow tr2 = new TableRow(); //如果没有主官,则首个单元格为空 if ((dt.Select("Department='" + dtDept.Rows[i][0].ToString() + "' And IsMonitor='0'")).Length < 0) { tcJob = new TableCell(); tcJob.Width = 50; tcJob.Text = ""; tr2.Cells.Add(tcJob); } for (int j = dr.Length - 1; j >= 0; j--) { //如果是三的整倍,则换行 if (tr2.Cells.Count > 3 || tr2.Cells.Count == 0) { tr2 = new TableRow(); //只有该部门有主官,或者是第一行,才要加空单元格 if ((dt.Select("Department='" + dtDept.Rows[i][0].ToString() + "' And IsMonitor='0'")).Length > 0 && j == (dr.Length - 1)) { } else { tcJob = new TableCell(); tcJob.Width = 50; tcJob.Text = ""; tr2.Cells.Add(tcJob); } } tcJob = new TableCell(); tcJob.HorizontalAlign = HorizontalAlign.Left; tcJob.Width = 140; //显示复选框,使员工可以多选 CheckBox cb = new CheckBox(); cb.Text = dr[j][1].ToString() + "● "; cb.ID = dr[j][0].ToString(); tcJob.Controls.Add(cb); cb.LabelAttributes.Add("onclick", "return window.showModalDialog( 'PopPage/StaffWorkPlan.aspx?StaffId=" + dr[j][0].ToString() + "','工作日程页面','dialogHeight=450, dialogWidth=600, top='+(screen.AvailHeight-450)/2+', left='+ (screen.availWidth-600)/2 +', toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')"); cb.LabelAttributes.Add("onmouseover", "return this.style.cursor='hand'"); //判断权限确定能够选择哪些员工 if (strPower == "Yes") { cb.Enabled = true; } else if (strPower == dtDept.Rows[i][1].ToString()) { cb.Enabled = true; } else { cb.Enabled = false; } string s = dr[j][4].ToString(); if (dr[j][4].ToString() != "") { if (Convert.ToDateTime(dr[j][4]) < Convert.ToDateTime("1900-1-1")) { tcJob.ForeColor = Color.Red; } else { tcJob.ForeColor = Color.Silver; } } tr2.Cells.Add(tcJob); tab.Rows.Add(tr2); tc1.Controls.Add(tab); tr1.Cells.Add(tc1); tlbIsOnline.Rows.Add(tr1); } } } } }
/// <summary> /// CustomerSensitive对象GetDataTable方法 /// </summary> private DataTable executeGetDataTable() { bool blnFirstField = true; string sql = "select * from CustomerSensitive"; // (SenCustomer_Guid)字段 if (_blnSenCustomer_GuidChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "SenCustomer_Guid like '%" + _SenCustomer_Guid + "%'"; } // (Mobile)字段 if (_blnMobileChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "Mobile like '%" + _Mobile + "%'"; } // (SenPeriod)字段 if (_blnSenPeriodChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "SenPeriod = " + _SenPeriod.ToString(); } // (SenEndTime)字段 if (_blnSenEndTimeChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "SenEndTime = '" + _SenEndTime.ToString() + "'"; } // (CreatedBy)字段 if (_blnCreatedByChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "CreatedBy like '%" + _CreatedBy + "%'"; } // (CreatedDate)字段 if (_blnCreatedDateChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "CreatedDate = '" + _CreatedDate.ToString() + "'"; } // (ModifiedBy)字段 if (_blnModifiedByChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "ModifiedBy like '%" + _ModifiedBy + "%'"; } // (ModifiedDate)字段 if (_blnModifiedDateChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "ModifiedDate = '" + _ModifiedDate.ToString() + "'"; } try { MDataBase db = new MDataBase(_DBConn); DataTable dt; bool blnReturnCode = db.GetDataTable(sql, out dt); if (blnReturnCode == false || dt == null) { return(null); } return(dt); } catch (Exception err) { throw; return(null); } }
public ArticleAddRule(string ConnetionString) { ConnStr = ConnetionString; db = new MDataBase(ConnStr); ControlDBind = new ControlDataBind(ConnStr); }
/// <summary> /// CustomerSensitive对象Update方法 /// </summary> private bool executeUpdate() { bool blnFirstField = true; string sql = "update CustomerSensitive set "; string sqlPK = " where "; // (SenCustomer_Guid)字段 sqlPK += "SenCustomer_Guid = '" + _SenCustomer_Guid + "'"; // (Mobile)字段 if (_blnMobileChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "Mobile = '" + _Mobile + "'"; } // (SenPeriod)字段 if (_blnSenPeriodChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "SenPeriod = " + _SenPeriod.ToString(); } // (SenEndTime)字段 if (_blnSenEndTimeChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "SenEndTime = '" + _SenEndTime.ToString() + "'"; } // (ModifiedBy)字段 if (_blnModifiedByChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "ModifiedBy = '" + _ModifiedBy + "'"; } // (ModifiedDate)字段 if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "ModifiedDate=GETDATE()"; sql += sqlPK; try { MDataBase db = new MDataBase(_DBConn); int intCount = db.executeUpdate(sql); return(true); } catch (Exception err) { throw; return(false); } }
/// <summary> /// CustomerSensitive对象GetInfo方法 /// </summary> private bool executeGetInfo() { bool blnFirstField = true; string sql = "select * from CustomerSensitive"; // (SenCustomer_Guid)字段 if (_blnSenCustomer_GuidChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "SenCustomer_Guid = '" + _SenCustomer_Guid + "'"; } // (Mobile)字段 if (_blnMobileChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "Mobile = '" + _Mobile + "'"; } // (SenPeriod)字段 if (_blnSenPeriodChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "SenPeriod = " + _SenPeriod.ToString(); } // (SenEndTime)字段 if (_blnSenEndTimeChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "SenEndTime = '" + _SenEndTime.ToString() + "'"; } // (CreatedBy)字段 if (_blnCreatedByChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "CreatedBy = '" + _CreatedBy + "'"; } // (CreatedDate)字段 if (_blnCreatedDateChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "CreatedDate = '" + _CreatedDate.ToString() + "'"; } // (ModifiedBy)字段 if (_blnModifiedByChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "ModifiedBy = '" + _ModifiedBy + "'"; } // (ModifiedDate)字段 if (_blnModifiedDateChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "ModifiedDate = '" + _ModifiedDate.ToString() + "'"; } try { MDataBase db = new MDataBase(_DBConn); DataRow dr; bool blnReturnCode = db.GetDataRow(sql, out dr); if (blnReturnCode == false || dr == null) { return(false); } // 对属性赋值 try { _SenCustomer_Guid = dr["SenCustomer_Guid"].ToString(); } catch (Exception err) {} try { _Mobile = dr["Mobile"].ToString(); } catch (Exception err) {} try { _SenPeriod = Convert.ToInt32(dr["SenPeriod"]); } catch (Exception err) {} try { _SenEndTime = Convert.ToDateTime(dr["SenEndTime"]); } catch (Exception err) {} try { _CreatedBy = dr["CreatedBy"].ToString(); } catch (Exception err) {} try { _CreatedDate = Convert.ToDateTime(dr["CreatedDate"]); } catch (Exception err) {} try { _ModifiedBy = dr["ModifiedBy"].ToString(); } catch (Exception err) {} try { _ModifiedDate = Convert.ToDateTime(dr["ModifiedDate"]); } catch (Exception err) {} return(true); } catch (Exception err) { throw; return(false); } }
/// <summary> /// CustomerSensitive对象Delete方法 /// </summary> private bool executeDelete() { bool blnFirstField = true; string sql = "delete from CustomerSensitive where "; // (SenCustomer_Guid)字段 if (_blnSenCustomer_GuidChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "SenCustomer_Guid = '" + _SenCustomer_Guid + "'"; } // (Mobile)字段 if (_blnMobileChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "Mobile = '" + _Mobile + "'"; } // (SenPeriod)字段 if (_blnSenPeriodChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "SenPeriod = " + _SenPeriod.ToString(); } // (SenEndTime)字段 if (_blnSenEndTimeChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "SenEndTime = '" + _SenEndTime.ToString() + "'"; } // (CreatedBy)字段 if (_blnCreatedByChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "CreatedBy = '" + _CreatedBy + "'"; } // (CreatedDate)字段 if (_blnCreatedDateChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "CreatedDate = '" + _CreatedDate.ToString() + "'"; } // (ModifiedBy)字段 if (_blnModifiedByChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "ModifiedBy = '" + _ModifiedBy + "'"; } // (ModifiedDate)字段 if (_blnModifiedDateChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "ModifiedDate = '" + _ModifiedDate.ToString() + "'"; } try { MDataBase db = new MDataBase(_DBConn); db.executeDelete(sql); return(true); } catch (Exception err) { throw; return(false); } }
/// <summary> /// CustomerSensitive对象Insert方法 /// </summary> private bool executeInsert() { bool blnFirstField = true; string sql = "insert into CustomerSensitive("; string sqlTmp = " values("; // (SenCustomer_Guid)字段 if (_blnSenCustomer_GuidChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "SenCustomer_Guid"; sqlTmp += "'" + _SenCustomer_Guid + "'"; } // (Mobile)字段 if (_blnMobileChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "Mobile"; sqlTmp += "'" + _Mobile + "'"; } // (SenPeriod)字段 if (_blnSenPeriodChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "SenPeriod"; sqlTmp += _SenPeriod.ToString(); } // (SenEndTime)字段 if (_blnSenEndTimeChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "SenEndTime"; sqlTmp += "'" + _SenEndTime.ToString() + "'"; } // (CreatedBy)字段 if (_blnCreatedByChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "CreatedBy"; sqlTmp += "'" + _CreatedBy + "'"; } // (CreatedDate)字段 if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "CreatedDate"; sqlTmp += "GETDATE()"; sql += ")" + sqlTmp + ")"; try { MDataBase db = new MDataBase(_DBConn); db.executeInsert(sql); return(true); } catch (Exception err) { throw; return(false); } }
public GetInformation(string ConnetionString) { ConnStr = ConnetionString; db = new MDataBase(ConnStr); }
/// <summary> /// SExmQuestion对象Delete方法 /// </summary> private bool executeDelete() { bool blnFirstField = true; string sql = "delete from SExmQuestion where "; // (Question_Guid)字段 if (_blnQuestion_GuidChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "Question_Guid = '" + _Question_Guid + "'"; } // (QuestionType_Id)字段 if (_blnQuestionType_IdChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "QuestionType_Id = '" + _QuestionType_Id + "'"; } // (Question)字段 if (_blnQuestionChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "Question = '" + _Question + "'"; } // (AnswerA)字段 if (_blnAnswerAChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "AnswerA = '" + _AnswerA + "'"; } // (AnswerB)字段 if (_blnAnswerBChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "AnswerB = '" + _AnswerB + "'"; } // (AnswerC)字段 if (_blnAnswerCChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "AnswerC = '" + _AnswerC + "'"; } // (AnswerD)字段 if (_blnAnswerDChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "AnswerD = '" + _AnswerD + "'"; } // (AnswerE)字段 if (_blnAnswerEChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "AnswerE = '" + _AnswerE + "'"; } // (Answer)字段 if (_blnAnswerChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "Answer = '" + _Answer + "'"; } // (Times)字段 if (_blnTimesChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "Times = " + _Times.ToString(); } // (CreatedBy)字段 if (_blnCreatedByChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "CreatedBy = '" + _CreatedBy + "'"; } // (CreatedDate)字段 if (_blnCreatedDateChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "CreatedDate = '" + _CreatedDate.ToString() + "'"; } // (ModifiedBy)字段 if (_blnModifiedByChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "ModifiedBy = '" + _ModifiedBy + "'"; } // (ModifiedDate)字段 if (_blnModifiedDateChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "ModifiedDate = '" + _ModifiedDate.ToString() + "'"; } // (StatusId)字段 if (_blnStatusIdChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "StatusId = " + _StatusId.ToString(); } try { MDataBase db = new MDataBase(_DBConn); db.executeDelete(sql); return(true); } catch (Exception err) { throw; return(false); } }
protected void btnStat_Click(object sender, EventArgs e) { /////////以下对每个人循环,每个人生成一行数据(如果不是管理员,则只能看到自已的,如果是部门管理员,则可以看到本部门的,如果是系统管理员,则可以看到全部的) //计算总在线时间(在历史表中得到) db = new MDataBase(config.DBConn); DataTable dtAllStaff = new DataTable(); string strGetStaff = ""; if (Function.CheckStaff(config) == "Yes")//系统管理员 { strGetStaff = "Select Staff_Id,Name From SSysStaff"; } else if (Function.CheckStaff(config) == "No")//不是管理员 { strGetStaff = "Select Staff_Id,Name From SSysStaff Where Staff_Id='" + config.Staff.Staff_Id + "'"; } else//部门管理员 { strGetStaff = "Select Staff_Id,Name From SSysStaff Where Dept_Id='" + Function.CheckStaff(config) + "'"; } db.GetDataTable(strGetStaff, out dtAllStaff); if (dtAllStaff.Rows.Count > 0) { //得到日程表中的数据 DataTable dtAllWorkTime = (DataTable)ViewState["dataSource"]; if (dtAllWorkTime != null) { //存放统计数据 DataTable dtWorkStat = new DataTable(); DataColumn dc3 = new DataColumn("OnlineTimes"); DataColumn dc4 = new DataColumn("WorkTimes"); DataColumn dc5 = new DataColumn("OutTimes"); DataColumn dc6 = new DataColumn("LeaveTimes"); DataColumn dc7 = new DataColumn("LeaveDays"); DataColumn dc8 = new DataColumn("WeekEndWorkDays"); dtWorkStat.Columns.Add(dc3); dtWorkStat.Columns.Add(dc4); dtWorkStat.Columns.Add(dc5); dtWorkStat.Columns.Add(dc6); dtWorkStat.Columns.Add(dc7); dtWorkStat.Columns.Add(dc8); //创建一行新数据 DataRow dr = dtWorkStat.NewRow(); //存放统计数据 int intOnlineTimes = 0, intWorkTimes = 0, intOutTimes = 0, intLeaveTimes = 0, intLeaveDays = 0, intWeekEndWorkDays = 0; for (int i = 0; i < dtAllStaff.Rows.Count; i++) { db = new MDataBase(config.DBConn); string strTimesCount = ""; db.GetDataScalar("Select sum(DATEDIFF(hour, LoginTime, LogoutTime)) AS TimesCount From SSysLoginHistory Where Staff_Id='" + dtAllStaff.Rows[i][0].ToString() + "'", ref strTimesCount); if (strTimesCount != "") { intOnlineTimes += Int32.Parse(strTimesCount); } //得到出勤次数(在作计划表中,状态为“出勤”的记录数) intWorkTimes += (dtAllWorkTime.Select("Staff_Id='" + dtAllStaff.Rows[i][0].ToString() + "' And WorkStatusId='6'")).Length; //得到外出办事次数(在作计划表中,状态为“外出”的记录数) intOutTimes += (dtAllWorkTime.Select("Staff_Id='" + dtAllStaff.Rows[i][0].ToString() + "' And WorkStatusId='7'")).Length; //得到请假次数(在作计划表中,状态为“请假”的记录数)?????(一次请几天假的情况) intLeaveTimes += (dtAllWorkTime.Select("Staff_Id='" + dtAllStaff.Rows[i][0].ToString() + "' And WorkStatusId='8'")).Length; //得到请假天数(暂为0) intLeaveDays += 0; //得到周末工作天数(暂为0) intWeekEndWorkDays += 0; } dr["OnlineTimes"] = intOnlineTimes; dr["WorkTimes"] = intWorkTimes; dr["OutTimes"] = intOutTimes; dr["LeaveTimes"] = intLeaveTimes; dr["LeaveDays"] = intLeaveDays; dr["WeekEndWorkDays"] = intWeekEndWorkDays; dtWorkStat.Rows.Add(dr); grvStatics.DataSource = dtWorkStat; grvStatics.DataBind(); } } }
/// <summary> /// 取外呼任务 /// </summary> /// <param name="StaffId">单个职员编码</param> /// <param name="StrategyId">单个组策略编码</param> /// <returns></returns> public static DataTable GetOBTask(string StaffId, string StrategyId) { while (_GetTaskStatus != 0 || _GetTaskFromDBStatus != 0) { Thread.Sleep(100); } _GetTaskStatus = 1; DataTable dtReturn = null; string sql; MDataBase db = new MDataBase(config.DBConn); db.Open(); try { // 刷新所有外呼任务 // 如果不需要刷新,则不刷新 RefreshOBTask(StaffId, StrategyId); // 取预约任务 if (_RespeakTaskPool.ContainsKey(StaffId) == true) { // 从_RespeakTaskPool取自已的最早的预约任务 Hashtable ht = (Hashtable)_RespeakTaskPool[StaffId]; DateTime nowTime = DateTime.Now; //当前时间 DateTime newTime = nowTime; //最小的预约时间 DataRow dr = null; foreach (DictionaryEntry de in ht) { if (Convert.ToDateTime(de.Key) < newTime) { // 小于最小的预约时间 newTime = Convert.ToDateTime(de.Key); dr = (DataRow)de.Value; } } if (newTime != nowTime) { DataTable dt; dt = new DataTable(); DataColumn column = new DataColumn(); column.DataType = typeof(string); column.Caption = "Task_Guid"; column.ColumnName = "Task_Guid"; dt.Columns.Add(column); DataColumn column2 = new DataColumn(); column2.DataType = typeof(string); column2.Caption = "Customer_Guid"; column2.ColumnName = "Customer_Guid"; dt.Columns.Add(column2); DataColumn column3 = new DataColumn(); column3.DataType = typeof(string); column3.Caption = "ItemName"; column3.ColumnName = "ItemName"; dt.Columns.Add(column3); dt.ImportRow(dr); dtReturn = dt; sql = "update SDrmTasks set Lock=0,LockTime=getDate(),ExecuteBy='" + StaffId + "' where Task_Guid='" + dt.Rows[0]["Task_Guid"].ToString() + "'"; int intCount = db.executeUpdate(sql); if (intCount > 0) { string tmp = newTime.ToString(); ht.Remove(tmp); } } } // 取个人任务 if (dtReturn == null && _SelfTaskPool.ContainsKey(StaffId) == true) { // 从_SelfTaskPool取个人任务 Hashtable ht = (Hashtable)_SelfTaskPool[StaffId]; DataTable dt; GetOnce(db, StaffId, ht, out dt); dtReturn = dt; } // 取抢占任务 if (dtReturn == null && (_RobTaskPool.ContainsKey(StrategyId) == true)) { // 从_RobTaskPool取抢占任务 Hashtable ht = (Hashtable)_RobTaskPool[StrategyId]; DataTable dt; GetOnce(db, StaffId, ht, out dt); dtReturn = dt; } } catch (Exception err) { //err.Message; } db.Close(); _GetTaskStatus = 0; return(dtReturn); }
protected void Page_Load(object sender, EventArgs e) { ////////////// CSSysStaff staff = new CSSysStaff(config.DBConn); staff.Staff_Id = "00000001"; config.Staff = staff; ////////////// if (!IsPostBack) { //添加弹出选择人员页面的属性 btnSelect.Attributes.Add("onclick", "PopWindow();"); //根据权限判断加载哪些记录 if (Function.CheckStaff(config) == "Yes")//为系统管理员 { BindData(""); //加载部门下拉框数据 db = new MDataBase(config.DBConn); string strDept = "Select * from SSysDepartment Where StatusId=0"; DataTable dtDept = new DataTable(); db.GetDataTable(strDept, out dtDept); ddlDept.Items.Clear(); ddlDept.Items.Add(new ListItem("全部", "0")); ddlDept.AppendDataBoundItems = true; ddlDept.DataSource = dtDept; ddlDept.DataTextField = "Name"; ddlDept.DataValueField = "Dept_Id"; ddlDept.DataBind(); //可以选择员工和部门 ddlDept.Enabled = true; btnSelect.Enabled = true; } else if (Function.CheckStaff(config) == "No")//不是管理员 { BindData("select a.*,b.UserName As UserName,b.Name As Name,c.Name AS StatusName from SPsnWorkTime a INNER JOIN SC_WorkStatus c ON a.WorkStatusId = c.WorkStatusId Left Join SSysStaff b On a.Staff_Id=b.Staff_Id Where a.StatusId=0 And Staff_Id='" + config.Staff.Staff_Id + "' And a.Day Between '" + DateTime.Now.AddDays(-7) + "' And '" + DateTime.Now + "'"); //不可以选择 btnSelect.Enabled = false; ddlDept.Enabled = false; } else//是部门的管理员 { //得到其所属的员工staff_Id db = new MDataBase(config.DBConn); string sqlStaff = "Select Staff_Id From SSysStaff Where Dept_Id='" + Function.CheckStaff(config) + "'"; DataTable dtStaff = new DataTable(); db.GetDataTable(sqlStaff, out dtStaff); string strStaffs = ""; for (int i = 0; i < dtStaff.Rows.Count; i++) { strStaffs += dtStaff.Rows[i][0].ToString() + "','"; } strStaffs = strStaffs.TrimEnd('\'').TrimEnd(','); BindData("select a.*,b.UserName As UserName,b.Name As Name,c.Name AS StatusName from SPsnWorkTime a INNER JOIN SC_WorkStatus c ON a.WorkStatusId = c.WorkStatusId Left Join SSysStaff b On a.Staff_Id=b.Staff_Id Where a.StatusId=0 And a.Staff_Id in('" + strStaffs + ") And a.Day Between '" + DateTime.Now.AddDays(-7) + "' And '" + DateTime.Now + "'"); //可以选择其所属部门员工 btnSelect.Enabled = true; ddlDept.Enabled = false; } lblCurrentPage.Text = "1"; } txtSelect.Text = Function.GetStaffNameById(hfStaffId.Value.TrimEnd(','), config); }
/// <summary> /// 取抢占任务 /// 包括前期加锁未外呼的任务(即Lock=0,Finish_Id is null,LockTime为40分钟前的任务) /// </summary> /// <param name="StrategyId">单个组策略编码</param> private static void GetRobTaskFromDB(string StrategyId) { try { string sql = "SELECT TOP " + RobTasks.ToString() + " A.Task_Guid, A.Customer_Guid, B.ItemName FROM SDrmTasks A LEFT OUTER JOIN SDrmItems B ON A.Item_Id = B.Item_Id WHERE A.Strategy_Id='" + StrategyId + "' and A.StartTime is null and A.Lock is null and A.Finish_Id is null and (B.BeginTime <= GETDATE()) AND (B.EndTime >= GETDATE()) AND (B.TaskLocation = 0) AND (B.WorkStatusId = 0) AND (B.StatusId = 0)"; MDataBase db = new MDataBase(config.DBConn); Hashtable ht = new Hashtable(); if (_RobTaskPool == null) { _RobTaskPool = new Hashtable(); } db.Open(); DataTable dt; bool blnReturnCode = db.GetDataTable(sql, out dt); if (blnReturnCode == true) { foreach (DataRow dr in dt.Rows) { ht.Add(dr["Task_Guid"].ToString(), dr); } // 如果抢占任务完成或快要完成,则取前期加锁未外呼的任务 if (dt.Rows.Count < RobTasks / 2) { //SELECT TOP 1 Task_Guid FROM SDrmTasks where " + strStrategyId + " and Finish_Id is null and Lock=0 and LockTime<=DATEADD(mi,30,getdate()) order by StartTime sql = "SELECT TOP " + Convert.ToString(RobTasks - dt.Rows.Count) + " A.Task_Guid, A.Customer_Guid, B.ItemName FROM SDrmTasks A LEFT OUTER JOIN SDrmItems B ON A.Item_Id = B.Item_Id WHERE A.Strategy_Id='" + StrategyId + "' AND A.Finish_Id is null AND A.Lock = 0 AND A.LockTime<=DATEADD(mi,-45,getdate()) AND (B.BeginTime <= GETDATE()) AND (B.EndTime >= GETDATE()) AND (B.TaskLocation = 0) AND (B.WorkStatusId = 0) AND (B.StatusId = 0) order by A.LockTime"; blnReturnCode = db.GetDataTable(sql, out dt); if (blnReturnCode == true) { foreach (DataRow dr in dt.Rows) { ht.Add(dr["Task_Guid"].ToString(), dr); } } } } db.Close(); // 记录更新的记录 if (_RobTaskPool.ContainsKey(StrategyId) == true) { _RobTaskPool.Remove(StrategyId); } _RobTaskPool.Add(StrategyId, ht); // 更新标记 if (_RobLastRefresh == null) { _RobLastRefresh = new Hashtable(); } if (_RobLastRefresh.ContainsKey(StrategyId) == true) { _RobLastRefresh[StrategyId] = ht.Count; } else { _RobLastRefresh.Add(StrategyId, ht.Count); } } catch { } }
protected void Page_Load(object sender, EventArgs e) { //测试调用情况 //Response.Write(this.Request.RawUrl); Config config = (Config)Session["Config"]; string strUsername = Request["txtLoginName"].ToString(); DataTable dtStaffRole; DataTable dtDelegateRole; string sql = ""; string sql2 = ""; string ReturnCode = ""; //string strStaffId; CSSysStaff staff = new CSSysStaff(config.DBConn); staff.Username = strUsername; staff.GetInfo(); //得到登录者所拥有的角色 sql = "SELECT B.Name, B.Role_Id AS Id FROM SSysStaffProjectRole A LEFT OUTER JOIN SSysRole B ON A.Role_Id = B.Role_Id WHERE A.Staff_Id = '" + staff.Staff_Id + "' AND A.Project_Id= '" + config.ProjectId + "' AND B.StatusId = 0"; MDataBase db = new MDataBase(config.DBConn); db.GetDataTable(sql, out dtStaffRole); for (int i = 0; i < dtStaffRole.Rows.Count; i++) { ReturnCode += dtStaffRole.Rows[i][1] + "*" + dtStaffRole.Rows[i][0] + "#"; } //得到登录者所代理的角色 if (config.IsCommission) { sql2 = ""; db.GetDataTable(sql2, out dtDelegateRole); for (int i = 0; i < dtDelegateRole.Rows.Count; i++) { ReturnCode += "(delegate)" + dtDelegateRole.Rows[i][1] + "*" + dtDelegateRole.Rows[i][0] + "#"; } } Response.ContentType = "text/plain"; Response.Write(ReturnCode); Response.End(); //if (dtStaffRole != null) //{ // ReturnCode += "<select name='sltRole' id='sltRole' style='width:130px;'>"; // bool IsFrist = true; // foreach (DataRow dr in dtStaffRole.Rows) // { // if (IsFrist == true) // { // ReturnCode += "<option selected=\"selected\" value=\""; // IsFrist = false; // } // else // { // ReturnCode += "<option value=\""; // } // ReturnCode += dr["Id"].ToString() + "\">" + dr["Name"].ToString() + "</option>"; // ReturnCode += "</select>"; // } //} ////<option selected="selected" value="Value1">Text1</option> ////<option value="Value2">Text2</option> //Response.Write(ReturnCode); }
/// <summary> /// SSysStaffProjectRole对象Delete方法 /// </summary> private bool executeDelete() { bool blnFirstField = true; string sql = "delete from SSysStaffProjectRole where "; // (Staff_Id)字段 if (_blnStaff_IdChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "Staff_Id = '" + _Staff_Id + "'"; } // (Project_Id)字段 if (_blnProject_IdChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "Project_Id = '" + _Project_Id + "'"; } // (Role_Id)字段 if (_blnRole_IdChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "Role_Id = '" + _Role_Id + "'"; } // (IsDefault)字段 if (_blnIsDefaultChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "IsDefault = " + _IsDefault.ToString(); } try { MDataBase db = new MDataBase(_DBConn); db.executeDelete(sql); return(true); } catch (Exception err) { throw; return(false); } }
/// <summary> /// SExmQuestion对象Update方法 /// </summary> private bool executeUpdate() { bool blnFirstField = true; string sql = "update SExmQuestion set "; string sqlPK = " where "; // (Question_Guid)字段 sqlPK += "Question_Guid = '" + _Question_Guid + "'"; // (QuestionType_Id)字段 if (_blnQuestionType_IdChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "QuestionType_Id = '" + _QuestionType_Id + "'"; } // (Question)字段 if (_blnQuestionChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "Question = '" + _Question + "'"; } // (AnswerA)字段 if (_blnAnswerAChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "AnswerA = '" + _AnswerA + "'"; } // (AnswerB)字段 if (_blnAnswerBChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "AnswerB = '" + _AnswerB + "'"; } // (AnswerC)字段 if (_blnAnswerCChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "AnswerC = '" + _AnswerC + "'"; } // (AnswerD)字段 if (_blnAnswerDChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "AnswerD = '" + _AnswerD + "'"; } // (AnswerE)字段 if (_blnAnswerEChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "AnswerE = '" + _AnswerE + "'"; } // (Answer)字段 if (_blnAnswerChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "Answer = '" + _Answer + "'"; } // (Times)字段 if (_blnTimesChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "Times = " + _Times.ToString(); } // (ModifiedBy)字段 if (_blnModifiedByChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "ModifiedBy = '" + _ModifiedBy + "'"; } // (ModifiedDate)字段 if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "ModifiedDate=GETDATE()"; // (StatusId)字段 if (_blnStatusIdChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "StatusId = " + _StatusId.ToString(); } sql += sqlPK; try { MDataBase db = new MDataBase(_DBConn); int intCount = db.executeUpdate(sql); return(true); } catch (Exception err) { throw; return(false); } }
/// <summary> /// SSysStaffProjectRole对象GetDataTable方法 /// </summary> private DataTable executeGetDataTableLike() { bool blnFirstField = true; string sql = "select * from SSysStaffProjectRole"; // (Staff_Id)字段 if (_blnStaff_IdChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "Staff_Id like '%" + _Staff_Id + "%'"; } // (Project_Id)字段 if (_blnProject_IdChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "Project_Id like '%" + _Project_Id + "%'"; } // (Role_Id)字段 if (_blnRole_IdChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "Role_Id like '%" + _Role_Id + "%'"; } // (IsDefault)字段 if (_blnIsDefaultChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "IsDefault = " + _IsDefault.ToString(); } try { MDataBase db = new MDataBase(_DBConn); DataTable dt; bool blnReturnCode = db.GetDataTable(sql, out dt); if (blnReturnCode == false || dt == null) { return(null); } return(dt); } catch (Exception err) { throw; return(null); } }
/// <summary> /// SExmQuestion对象GetInfo方法 /// </summary> private bool executeGetInfo() { bool blnFirstField = true; string sql = "select * from SExmQuestion"; // (Question_Guid)字段 if (_blnQuestion_GuidChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "Question_Guid = '" + _Question_Guid + "'"; } // (QuestionType_Id)字段 if (_blnQuestionType_IdChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "QuestionType_Id = '" + _QuestionType_Id + "'"; } // (Question)字段 if (_blnQuestionChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "Question = '" + _Question + "'"; } // (AnswerA)字段 if (_blnAnswerAChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "AnswerA = '" + _AnswerA + "'"; } // (AnswerB)字段 if (_blnAnswerBChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "AnswerB = '" + _AnswerB + "'"; } // (AnswerC)字段 if (_blnAnswerCChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "AnswerC = '" + _AnswerC + "'"; } // (AnswerD)字段 if (_blnAnswerDChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "AnswerD = '" + _AnswerD + "'"; } // (AnswerE)字段 if (_blnAnswerEChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "AnswerE = '" + _AnswerE + "'"; } // (Answer)字段 if (_blnAnswerChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "Answer = '" + _Answer + "'"; } // (Times)字段 if (_blnTimesChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "Times = " + _Times.ToString(); } // (CreatedBy)字段 if (_blnCreatedByChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "CreatedBy = '" + _CreatedBy + "'"; } // (CreatedDate)字段 if (_blnCreatedDateChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "CreatedDate = '" + _CreatedDate.ToString() + "'"; } // (ModifiedBy)字段 if (_blnModifiedByChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "ModifiedBy = '" + _ModifiedBy + "'"; } // (ModifiedDate)字段 if (_blnModifiedDateChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "ModifiedDate = '" + _ModifiedDate.ToString() + "'"; } // (StatusId)字段 if (_blnStatusIdChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "StatusId = " + _StatusId.ToString(); } try { MDataBase db = new MDataBase(_DBConn); DataRow dr; bool blnReturnCode = db.GetDataRow(sql, out dr); if (blnReturnCode == false || dr == null) { return(false); } // 对属性赋值 try { _Question_Guid = dr["Question_Guid"].ToString(); } catch (Exception err) {} try { _QuestionType_Id = dr["QuestionType_Id"].ToString(); } catch (Exception err) {} try { _Question = dr["Question"].ToString(); } catch (Exception err) {} try { _AnswerA = dr["AnswerA"].ToString(); } catch (Exception err) {} try { _AnswerB = dr["AnswerB"].ToString(); } catch (Exception err) {} try { _AnswerC = dr["AnswerC"].ToString(); } catch (Exception err) {} try { _AnswerD = dr["AnswerD"].ToString(); } catch (Exception err) {} try { _AnswerE = dr["AnswerE"].ToString(); } catch (Exception err) {} try { _Answer = dr["Answer"].ToString(); } catch (Exception err) {} try { _Times = Convert.ToInt32(dr["Times"]); } catch (Exception err) {} try { _CreatedBy = dr["CreatedBy"].ToString(); } catch (Exception err) {} try { _CreatedDate = Convert.ToDateTime(dr["CreatedDate"]); } catch (Exception err) {} try { _ModifiedBy = dr["ModifiedBy"].ToString(); } catch (Exception err) {} try { _ModifiedDate = Convert.ToDateTime(dr["ModifiedDate"]); } catch (Exception err) {} try { _StatusId = Convert.ToInt32(dr["StatusId"]); } catch (Exception err) {} return(true); } catch (Exception err) { throw; return(false); } }
//ControlDataBind ControlDBind; public KnowledgeMaintenanceRule(string ConnetionString) { ConnStr = ConnetionString; db = new MDataBase(ConnStr); //ControlDBind = new ControlDataBind(ConnStr); }
/// <summary> /// SExmQuestion对象GetDataTable方法 /// </summary> private DataTable executeGetDataTableLike() { bool blnFirstField = true; string sql = "select * from SExmQuestion"; // (Question_Guid)字段 if (_blnQuestion_GuidChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "Question_Guid like '%" + _Question_Guid + "%'"; } // (QuestionType_Id)字段 if (_blnQuestionType_IdChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "QuestionType_Id like '%" + _QuestionType_Id + "%'"; } // (Question)字段 if (_blnQuestionChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "Question like '%" + _Question + "%'"; } // (AnswerA)字段 if (_blnAnswerAChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "AnswerA like '%" + _AnswerA + "%'"; } // (AnswerB)字段 if (_blnAnswerBChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "AnswerB like '%" + _AnswerB + "%'"; } // (AnswerC)字段 if (_blnAnswerCChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "AnswerC like '%" + _AnswerC + "%'"; } // (AnswerD)字段 if (_blnAnswerDChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "AnswerD like '%" + _AnswerD + "%'"; } // (AnswerE)字段 if (_blnAnswerEChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "AnswerE like '%" + _AnswerE + "%'"; } // (Answer)字段 if (_blnAnswerChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "Answer like '%" + _Answer + "%'"; } // (Times)字段 if (_blnTimesChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "Times = " + _Times.ToString(); } // (CreatedBy)字段 if (_blnCreatedByChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "CreatedBy like '%" + _CreatedBy + "%'"; } // (CreatedDate)字段 if ((_blnCreatedDateStartChanged == true) || (_blnCreatedDateEndChanged == true)) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "CreatedDate BETWEEN '" + _CreatedDateStart.ToString() + "' AND '" + _CreatedDateEnd.ToString() + "'"; } // (ModifiedBy)字段 if (_blnModifiedByChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "ModifiedBy like '%" + _ModifiedBy + "%'"; } // (ModifiedDate)字段 if ((_blnModifiedDateStartChanged == true) || (_blnModifiedDateEndChanged == true)) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "ModifiedDate BETWEEN '" + _ModifiedDateStart.ToString() + "' AND '" + _ModifiedDateEnd.ToString() + "'"; } // (StatusId)字段 if (_blnStatusIdChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "StatusId = " + _StatusId.ToString(); } try { MDataBase db = new MDataBase(_DBConn); DataTable dt; bool blnReturnCode = db.GetDataTable(sql, out dt); if (blnReturnCode == false || dt == null) { return(null); } return(dt); } catch (Exception err) { throw; return(null); } }
/// <summary> /// SExmScore对象GetDataTable方法 /// </summary> private DataTable executeGetDataTableLike() { bool blnFirstField = true; string sql = "select * from SExmScore"; // (Score_Guid)字段 if (_blnScore_GuidChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "Score_Guid like '%" + _Score_Guid + "%'"; } // (Exam_Id)字段 if (_blnExam_IdChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "Exam_Id like '%" + _Exam_Id + "%'"; } // (Staff_Id)字段 if (_blnStaff_IdChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "Staff_Id like '%" + _Staff_Id + "%'"; } // (StartTime)字段 if ((_blnStartTimeStartChanged == true) || (_blnStartTimeEndChanged == true)) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "StartTime BETWEEN '" + _StartTimeStart.ToString() + "' AND '" + _StartTimeEnd.ToString() + "'"; } // (EndTime)字段 if ((_blnEndTimeStartChanged == true) || (_blnEndTimeEndChanged == true)) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "EndTime BETWEEN '" + _EndTimeStart.ToString() + "' AND '" + _EndTimeEnd.ToString() + "'"; } // (RightCount)字段 if (_blnRightCountChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "RightCount = " + _RightCount.ToString(); } // (WrongCount)字段 if (_blnWrongCountChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "WrongCount = " + _WrongCount.ToString(); } // (UnfinishCount)字段 if (_blnUnfinishCountChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "UnfinishCount = " + _UnfinishCount.ToString(); } // (Score)字段 if (_blnScoreChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "Score = " + _Score.ToString(); } // (Gradation)字段 if (_blnGradationChanged == true) { if (blnFirstField == true) { blnFirstField = false; sql += " WHERE "; } else { sql += " AND "; } sql += "Gradation = " + _Gradation.ToString(); } try { MDataBase db = new MDataBase(_DBConn); DataTable dt; bool blnReturnCode = db.GetDataTable(sql, out dt); if (blnReturnCode == false || dt == null) { return(null); } return(dt); } catch (Exception err) { throw; return(null); } }
/// <summary> /// SExmQuestion对象Insert方法 /// </summary> private bool executeInsert() { bool blnFirstField = true; string sql = "insert into SExmQuestion("; string sqlTmp = " values("; // (Question_Guid)字段 if (_blnQuestion_GuidChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "Question_Guid"; sqlTmp += "'" + _Question_Guid + "'"; } // (QuestionType_Id)字段 if (_blnQuestionType_IdChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "QuestionType_Id"; sqlTmp += "'" + _QuestionType_Id + "'"; } // (Question)字段 if (_blnQuestionChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "Question"; sqlTmp += "'" + _Question + "'"; } // (AnswerA)字段 if (_blnAnswerAChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "AnswerA"; sqlTmp += "'" + _AnswerA + "'"; } // (AnswerB)字段 if (_blnAnswerBChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "AnswerB"; sqlTmp += "'" + _AnswerB + "'"; } // (AnswerC)字段 if (_blnAnswerCChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "AnswerC"; sqlTmp += "'" + _AnswerC + "'"; } // (AnswerD)字段 if (_blnAnswerDChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "AnswerD"; sqlTmp += "'" + _AnswerD + "'"; } // (AnswerE)字段 if (_blnAnswerEChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "AnswerE"; sqlTmp += "'" + _AnswerE + "'"; } // (Answer)字段 if (_blnAnswerChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "Answer"; sqlTmp += "'" + _Answer + "'"; } // (Times)字段 if (_blnTimesChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "Times"; sqlTmp += _Times.ToString(); } // (CreatedBy)字段 if (_blnCreatedByChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "CreatedBy"; sqlTmp += "'" + _CreatedBy + "'"; } // (CreatedDate)字段 if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "CreatedDate"; sqlTmp += "GETDATE()"; // (StatusId)字段 if (_blnStatusIdChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "StatusId"; sqlTmp += _StatusId.ToString(); } sql += ")" + sqlTmp + ")"; try { MDataBase db = new MDataBase(_DBConn); db.executeInsert(sql); return(true); } catch (Exception err) { throw; return(false); } }
/// <summary> /// SExmScore对象Delete方法 /// </summary> private bool executeDelete() { bool blnFirstField = true; string sql = "delete from SExmScore where "; // (Score_Guid)字段 if (_blnScore_GuidChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "Score_Guid = '" + _Score_Guid + "'"; } // (Exam_Id)字段 if (_blnExam_IdChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "Exam_Id = '" + _Exam_Id + "'"; } // (Staff_Id)字段 if (_blnStaff_IdChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "Staff_Id = '" + _Staff_Id + "'"; } // (StartTime)字段 if (_blnStartTimeChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "StartTime = '" + _StartTime.ToString() + "'"; } // (EndTime)字段 if (_blnEndTimeChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "EndTime = '" + _EndTime.ToString() + "'"; } // (RightCount)字段 if (_blnRightCountChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "RightCount = " + _RightCount.ToString(); } // (WrongCount)字段 if (_blnWrongCountChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "WrongCount = " + _WrongCount.ToString(); } // (UnfinishCount)字段 if (_blnUnfinishCountChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "UnfinishCount = " + _UnfinishCount.ToString(); } // (Score)字段 if (_blnScoreChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "Score = " + _Score.ToString(); } // (Gradation)字段 if (_blnGradationChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += " AND "; } sql += "Gradation = " + _Gradation.ToString(); } try { MDataBase db = new MDataBase(_DBConn); db.executeDelete(sql); return(true); } catch (Exception err) { throw; return(false); } }
///// <summary> ///// SSysErrorLog对象Delete方法 ///// </summary> //public bool Delete() //{ // return executeDelete(); //} ///// <summary> ///// SSysErrorLog对象Update方法 ///// </summary> //public bool Update() //{ // return executeUpdate(); //} ///// <summary> ///// 取SSysErrorLog对象信息方法 ///// 通过对象属性得到方法返回值 ///// </summary> //public bool GetInfo() //{ // return executeGetInfo(); //} ///// <summary> ///// SSysErrorLog对象查询数据表方法 ///// </summary> //public DataTable GetDataTable() //{ // return executeGetDataTable(); //} ///// <summary> ///// SSysErrorLog对象查询数据表方法 ///// </summary> //public DataTable GetDataTable(bool blnLike) //{ // if (blnLike == true) // { // return executeGetDataTableLike(); // } // else // { // return executeGetDataTable(); // } //} #endregion #region executeInsert /// <summary> /// SSysErrorLog对象Insert方法 /// </summary> private bool executeInsert() { bool blnFirstField = true; string sql = "insert into SSysErrorLog("; string sqlTmp = " values("; // (ID)字段 if (_blnIDChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "ID"; sqlTmp += "'" + _ID + "'"; } // (Message)字段 if (_blnMessageChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "Message"; sqlTmp += "'" + _Message + "'"; } // (Src)字段 if (_blnSrcChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "Src"; sqlTmp += "'" + _Src + "'"; } // (CreatedDate)字段 if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "CreatedDate"; sqlTmp += "GETDATE()"; // (Staff_Id)字段 if (_blnStaff_IdChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; sqlTmp += ","; } sql += "Staff_Id"; sqlTmp += "'" + _Staff_Id + "'"; } sql += ")" + sqlTmp + ")"; try { MDataBase db = new MDataBase(_DBConn); db.executeInsert(sql); return(true); } catch (Exception err) { eventLog(err); return(false); } }