/// <summary> /// SC_QuestionType对象Update方法 /// </summary> private bool executeUpdate() { bool blnFirstField = true; string sql = "update SC_QuestionType set "; string sqlPK = " where "; // (QuestionType_Id)字段 sqlPK += "QuestionType_Id = '" + _QuestionType_Id + "'"; // (QuestionTypeName)字段 if (_blnQuestionTypeNameChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "QuestionTypeName = '" + _QuestionTypeName + "'"; } sql += sqlPK; try { MDataBase db = new MDataBase(_DBConn); int intCount = db.executeUpdate(sql); return(true); } catch (Exception err) { throw; return(false); } }
protected void btnSave_Click(object sender, EventArgs e) { //得到要插入的新的角色编号 string strId = Guid.NewGuid().ToString().Substring(0, 8); string supId = cblFunctionSelect.SelectedValue; string name = txtRoleName.Text; string comment = txtRoleNote.Text; if (name == "") { //当没有输入角色名称时,弹出警告窗口 Response.Write("<script type='text/javascript'>alert('请输入角色名称!')</script>"); } else { db = new MDataBase(config.DBConn); //向数据库中插入新角色 if (hfIsUpdate.Value == "Insert") { //向数据库中插入新角色 string strRoleSql = "INSERT INTO SSysRole (Role_Id,Project_Id, Name, CreatedDate, StatusId) values('" + strId + "','" + config.ProjectId + "','" + name + "','" + DateTime.Now + "','0')"; db.executeInsert(strRoleSql); //向数据库中插入角色功能关系 for (int i = 0; i < cblFunctionSelect.Items.Count; i++) { if (cblFunctionSelect.Items[i].Selected) { string strRoleFuncSql = "Insert Into SSysRoleFunction values('" + strId + "','" + cblFunctionSelect.Items[i].Value + "')"; db.executeInsert(strRoleFuncSql); } } } else { //更新角色数据 string sqlUpdate = "UPDATE SSysRole SET Project_Id='" + config.ProjectId + "',Name='" + name + "',ModifiedDate='" + DateTime.Now + "' WHERE Role_Id='" + hfIsUpdate.Value + "'"; db.executeUpdate(sqlUpdate); //先删除相关角色功能关系 string sqlDelete = "Delete from SSysRoleFunction Where Role_Id='" + hfIsUpdate.Value + "'"; db.executeDelete(sqlDelete); //向数据库中插入角色功能关系 for (int i = 0; i < cblFunctionSelect.Items.Count; i++) { if (cblFunctionSelect.Items[i].Selected) { string strRoleFuncSql = "Insert Into SSysRoleFunction values('" + hfIsUpdate.Value + "','" + cblFunctionSelect.Items[i].Value + "')"; db.executeInsert(strRoleFuncSql); } } Response.Write("<script>window.dialogArguments.reload();</script>"); } } }
//领导同意批示保存 private string EditTYPS(string OrderArrange_Guid) { string OrderNotion = txtOrderNotion.Text.Trim(); //领导意见 string UpdateNotion = "UPDATE SZOrdAuditing set [OrderNotion] = '" + OrderNotion + "',[IsPer] = '1', PerNumber = '" + ViewState["Satff_Id"].ToString() + "', [CreatedBy] = '" + ViewState["Satff_Id"].ToString() + "',[CreatedDate] = getdate(), [ModifiedBy] = '" + ViewState["Satff_Id"].ToString() + "',[ModifiedDate] = getdate() WHERE Order_ID = '" + ViewState["Order_ID"].ToString() + "' and OrderArrange_Guid = '" + OrderArrange_Guid + "'"; try { db.executeUpdate(UpdateNotion); return("修改成功"); } catch (Exception er) { return(er.Message); } }
//插入平均分到考试表 private void AverageAdd() { string sql = "select avg(score) from SExmScore where Exam_Id='" + Session["Guid"].ToString() + "'"; DataTable dt = new DataTable(); db = new MDataBase(config.DBConn); db.GetDataTable(sql, out dt); float Average = Convert.ToInt32(dt.Rows[0]); string sqlin = "UPDATE SExmExam set Average='" + Average + "')"; db = new MDataBase(config.DBConn); db.executeUpdate(sqlin); }
//插入分数到成绩表的方法,正确数/总题数 private void ScoreAdd() { string sql = "select RightCount from SExmScore where Exam_Id='" + Session["Guid"].ToString() + "'"; DataTable dt = new DataTable(); db = new MDataBase(config.DBConn); db.GetDataTable(sql, out dt); //取得正确题数 int RightCount = dt.Rows.Count; //取得平均分的方法(正确数/总题数) float Score = RightCount / Convert.ToInt32(Session["Count"]); string sqlin = "UPDATE SExmScore set Score='" + Score + "'"; db = new MDataBase(config.DBConn); db.executeUpdate(sqlin); }
//保存考题信息(对,错,未做)到成绩表 private void QuestionAdd() { //先检索临时表,得到考题信息 string sql = "select QuestionState,count(*) as sum from temp" + config.Staff.Username + " group by QuestionState"; DataTable dt = new DataTable(); db = new MDataBase(config.DBConn); db.GetDataTable(sql, out dt); string aa = dt.Rows[0]["sum"].ToString(); string bb = dt.Rows[1]["sum"].ToString(); string cc = dt.Rows[2]["sum"].ToString(); //插入考题信息 string sqlin = "update SExmScore set RightCount='" + bb + "',WrongCount='" + cc + "',UnfinishCount='" + aa + "'"; db = new MDataBase(config.DBConn); db.executeUpdate(sqlin); }
/// <summary> /// 角色删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDelete_Click(object sender, EventArgs e) { ArrayList list = GetSelectedKeyValues(out isDelete); //循环删除数据 if (list.Count != 0) { //将角色表中的对应记录,标记为不可用 string sql = "UPDATE SSysRole SET StatusId=-1 WHERE Role_Id in ("; //将与该Role_Id对应的SSysRoleFunction表中的记录删除 string sqlDelete = "Delete from SSysRoleFunction Where Role_Id in("; string strIndex = ""; for (int i = 0; i < list.Count; i++) { strIndex += "'" + list[i].ToString() + "',"; } sql = sql + strIndex.TrimEnd(',') + ")"; sqlDelete = sqlDelete + strIndex.TrimEnd(',') + ")"; try { db = new MDataBase(config.DBConn); db.executeUpdate(sql); db.executeDelete(sqlDelete); Response.Write("<script type='text/javascript'>alert('删除成功!');window.location.href=window.location.href;</script>"); } catch (Exception exc) { } finally { Response.Write("<script type='text/javascript'>window.location.href=window.location.href;</script>"); } } else { Response.Write("<script type='text/javascript'>alert('请选择要删除的部门!');</script>"); } }
/// <summary> /// 从Hashtable容器中取一条记录并转换为DataTable类型 /// </summary> /// <param name="StaffId">操作员编码</param> /// <param name="ht">Hashtable容器</param> /// <param name="dt">包含一条记录的DataTable,失败返回Null</param> private static void GetOnce(MDataBase db, string StaffId, Hashtable ht, out DataTable dt) { dt = null; if (ht != null && ht.Count > 0) { 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); DataRow dr = null; foreach (DictionaryEntry de in ht) { dr = (DataRow)de.Value; break; } if (dr != null) { dt.ImportRow(dr); string TaskGuid = dr["Task_Guid"].ToString(); string sql = "update SDrmTasks set Lock=0,LockTime=getDate(),ExecuteBy='" + StaffId + "' where Task_Guid='" + TaskGuid + "'"; int intCount = db.executeUpdate(sql); if (intCount > 0) { ht.Remove(TaskGuid); } } } }
/// <summary> /// SSysRunParameter对象Update方法 /// </summary> private bool executeUpdate() { bool blnFirstField = true; string sql = "update SSysRunParameter set "; string sqlPK = " where "; // (Parameter_Guid)字段 sqlPK += "Parameter_Guid = '" + _Parameter_Guid + "'"; // (ParameterName)字段 if (_blnParameterNameChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "ParameterName = '" + _ParameterName + "'"; } // (ParameterValue)字段 if (_blnParameterValueChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "ParameterValue = '" + _ParameterValue + "'"; } // (Detail)字段 if (_blnDetailChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "Detail = '" + _Detail + "'"; } // (IsUser)字段 if (_blnIsUserChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "IsUser = " + _IsUser.ToString(); } sql += sqlPK; try { MDataBase db = new MDataBase(_DBConn); int intCount = db.executeUpdate(sql); return(true); } catch (Exception err) { throw; return(false); } }
/// <summary> /// SExmScore对象Update方法 /// </summary> private bool executeUpdate() { bool blnFirstField = true; string sql = "update SExmScore set "; string sqlPK = " where "; // (Score_Guid)字段 sqlPK += "Score_Guid = '" + _Score_Guid + "'"; // (Exam_Id)字段 if (_blnExam_IdChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "Exam_Id = '" + _Exam_Id + "'"; } // (Staff_Id)字段 if (_blnStaff_IdChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "Staff_Id = '" + _Staff_Id + "'"; } // (StartTime)字段 if (_blnStartTimeChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "StartTime = '" + _StartTime.ToString() + "'"; } // (EndTime)字段 if (_blnEndTimeChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "EndTime = '" + _EndTime.ToString() + "'"; } // (RightCount)字段 if (_blnRightCountChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "RightCount = " + _RightCount.ToString(); } // (WrongCount)字段 if (_blnWrongCountChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "WrongCount = " + _WrongCount.ToString(); } // (UnfinishCount)字段 if (_blnUnfinishCountChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "UnfinishCount = " + _UnfinishCount.ToString(); } // (Score)字段 if (_blnScoreChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "Score = " + _Score.ToString(); } // (Gradation)字段 if (_blnGradationChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "Gradation = " + _Gradation.ToString(); } sql += sqlPK; try { MDataBase db = new MDataBase(_DBConn); int intCount = db.executeUpdate(sql); return(true); } catch (Exception err) { throw; return(false); } }
//办公室保存 private string SaveSY() { string GUID = ""; if (ViewState["Number"] != null && ViewState["Number"].ToString() != "") //得到前面生成的GUID { GUID = ViewState["Number"].ToString(); } string selectSql = "select top 1 Tel_TelTime,InceptMode,TelCom,TelMeet,TelUnit," + " MostlyContent,Abjunct from STelEnrol where Tel_ID = '" + Tel_ID + "' order by CreatedDate"; DataRow selectRow = db.GetDataRow(selectSql); //来电时间 if (txtTelFTime.Text == "") { txtTelFTime.Text = "00"; } string time = txtTelRTime.Text + " " + drpTelSTime.SelectedValue + ":" + txtTelFTime.Text + ":00"; //接收方式 string InceptMode = drpInceptMode.SelectedIndex.ToString(); //来电人 string TelCom = txtTelCom.Text.Trim(); //接电人 string TelMeet = txtTelMeet.Text.Trim(); //来电单位 string TelUnit = txtTelUnit.Text.Trim(); //主要内容 string MostlyContent = txtMostlyContent.Text.Trim(); //附件:AAA string GVAbjunctOne = ""; if (ViewState["AttachmentBatch_Guid"] == null || ViewState["AttachmentBatch_Guid"].ToString() == "") { } else { GVAbjunctOne = ViewState["AttachmentBatch_Guid"].ToString(); //要改的 } //验证 try { Convert.ToDateTime(time); } catch { return("日期的格式不正确,请重新输入"); } if (InceptMode == "") { return("请选择接收方式"); } if (TelCom == "") { return("请输入来电人"); } if (TelMeet == "") { return("请输入接电人"); } if (TelUnit == "") { return("请输入来电单位"); } if (selectRow[1].ToString() != InceptMode || //对比接收方式是否一致 selectRow[2].ToString() != TelCom || //对比来电人是否一致 selectRow[3].ToString() != TelMeet || //对比接电人是否一致 selectRow[4].ToString() != TelUnit || //对比来电单位是否一致 selectRow[5].ToString() != MostlyContent) //对比主要内容是否一致 //对比附件是否一致 || selectRow[9].ToString() != GVAbjunctOne { string InsertDJ = ""; if (ViewState["QZ"] != null && ViewState["QZ"].ToString() != "" && ViewState["QZ"].ToString() == "True") { InsertDJ = "insert into STelEnrol(GUID,Tel_ID,Tel_TelTime,InceptMode,TelCom,TelMeet,TelUnit,MostlyContent,Abjunct,Personnel,CreatedBy,CreatedDate,Note_ID)" + "values('" + GUID + "','" + Tel_ID + "','" + time + "','" + InceptMode + "','" + TelCom + "','" + TelMeet + "','" + TelUnit + "','" + MostlyContent + "','" + GVAbjunctOne + "','" + ViewState["Satff_Id"].ToString() + "','" + ViewState["Satff_Id"].ToString() + "',getdate(),1)"; ViewState["QZ"] = ""; } else { InsertDJ = "insert into STelEnrol(GUID,Tel_ID,Tel_TelTime,InceptMode,TelCom,TelMeet,TelUnit,MostlyContent,Abjunct,CreatedBy,CreatedDate,Note_ID)" + "values('" + GUID + "','" + Tel_ID + "','" + time + "','" + InceptMode + "','" + TelCom + "','" + TelMeet + "','" + TelUnit + "','" + MostlyContent + "','" + GVAbjunctOne + "','" + ViewState["Satff_Id"].ToString() + "',getdate(),1)"; } try { db.executeInsert(InsertDJ); return("保存成功"); } catch (Exception er) { return(er.Message); } } else { //只要点保存就默认同意 string UpdateDJ = "Update STelEnrol set Personnel = '" + ViewState["Satff_Id"].ToString() + "' where Tel_Id = '" + Tel_ID + "'"; //更新签名 try { db.executeUpdate(UpdateDJ); GUID = db.GetDataScalar("select GUID from STelEnrol where Tel_Id = '" + Tel_ID + "'"); string Update = "Update STelFlow set Number = '" + GUID + "' where Tel_ID = '" + Tel_ID + "' and operateStep = '1'"; db.executeUpdate(Update); ViewState["Number"] = GUID; //如果没有更新要把原来的编号付值回去 return("审批成功"); } catch (Exception er) { return(er.Message); } } }
protected void BtnSave_Click(object sender, EventArgs e) { if (drpOrder_ID.SelectedValue == "0") { WebWindow.alert("请选择要操作的勤务的编号"); return; } string Order_ID = drpOrder_ID.SelectedValue; //勤务编号 string EnregisterTime = this.lblEnregisterTime.Text.Trim() + " 00:00:00"; string GuardSpec = drpGuardSpec.SelectedValue; //警卫规格: string TaskName = txtTaskName.Text.Trim(); //警卫名称 string DayNumber = txtDayNumber.Text.Trim(); // 抵达情况: try { Convert.ToInt32(txtDayNumber.Text.Trim()); } catch { WebWindow.alert("抵达天数请输入日期型"); return; } string ArrivalTime = txtArrivalTime1.Text.Trim() + " " + drpArrivalTime2.Text.Trim() + ":00:00"; //日期加小时加分秒 try { Convert.ToDateTime(ArrivalTime); } catch { WebWindow.alert("抵达时间请输入日期型"); return; } string FromArea = txtFromArea.Text.Trim(); //自 string RiteVehicle = txtRiteVehicle.Text.Trim(); // 乘 string ArrivalArea = txtArrivalArea.Text.Trim(); //抵 string ArrivalTimeTwo = txtArrivalTimeTwo1.Text.Trim() + " " + this.drpArrivalTimeTwo2.Text.Trim() + ":00:00"; //日期加小时加分秒 try { Convert.ToDateTime(ArrivalTimeTwo); } catch { WebWindow.alert("抵达时间请输入日期型"); return; } string FromAreaTwo = txtFromAreaTwo.Text.Trim(); //自 string RiteVehicleTwo = txtRiteVehicleTwo.Text.Trim(); // 乘 string ArrivalAreaTwo = txtArrivalAreaTwo.Text.Trim(); //抵 string ReceiveArea = txtReceiveArea.Text.Trim(); // 接待单位: string AccompanyFugl = txtAccompanyFugle.Text.Trim(); // 省陪同领导: string MoveDate = txtMoveDate.Text.Trim(); // 活动日程: string AccompanyPeo = txtAccompanyPeo.Text.Trim(); // 随行人员(姓名/职务): string GuardCuston = txtGuardCuston.Text.Trim(); // 警卫对象生活习惯: string Principal = txtPrincipal.Text.Trim(); // 负责人: string Roster = txtRoster.Text.Trim(); // 值勤人员: string Perform = txtPerform.Text.Trim(); string Remark = txtRemark.Text.Trim(); // 备注: string CreatedBy = txtCreatedBy.Text.Trim(); // 填表人: if (ViewState["State"] == null || ViewState["State"].ToString() == null) { Response.Redirect("error2.htm"); } else { if (ViewState["State"].ToString() == "Insert") { string Insert = "INSERT INTO SOrdNWBenregister ([Order_ID] ,[EnregisterTime] ,[GuardSpec] ,[DayNumber] ,[ArrivalTime] ,[FromArea] ,[RiteVehicle] ," + "[ArrivalArea] ,[ArrivalTimeTwo] ,[FromAreaTwo] ,[RiteVehicleTwo] ,[ArrivalAreaTwo] ,[ReceiveArea] ,[AccompanyFugle] ,[MoveDate] ," + "[AccompanyPeo] ,[GuardCuston] ,[Principal] ,[Roster] ,[Perform] ,[Remark] ,[CreatedBy] ,[CreatedDate]) VALUES " + "('" + Order_ID + "','" + EnregisterTime + "','" + GuardSpec + "','" + DayNumber + "','" + ArrivalTime + "','" + FromArea + "','" + RiteVehicle + "','" + ArrivalArea + "','" + ArrivalTimeTwo + "','" + FromAreaTwo + "','" + RiteVehicleTwo + "','" + ArrivalAreaTwo + "','" + ReceiveArea + "','" + AccompanyFugl + "','" + MoveDate + "','" + AccompanyPeo + "','" + GuardCuston + "','" + Principal + "','" + Roster + "','" + Perform + "','" + Remark + "','" + CreatedBy + "',getdate())"; try { db.executeInsert(Insert); WebWindow.alert("保存成功"); } catch (Exception er) { WebWindow.alert(er.Message); } } else if (ViewState["State"].ToString() == "Update") { if (ViewState["Order_ID"] == null || ViewState["Order_ID"].ToString() == "") { Response.Redirect("error2.htm"); } string ModifiedBy = ""; string Update = "UPDATE SOrdNWBenregister set [GuardSpec] = '" + GuardSpec + "',[DayNumber] = '" + DayNumber + "',[ArrivalTime]= '" + ArrivalTime + "',[FromArea] = '" + FromArea + "',[RiteVehicle] = '" + RiteVehicle + "',[ArrivalArea] = '" + ArrivalArea + "', [ArrivalTimeTwo] = '" + ArrivalTimeTwo + "',[FromAreaTwo] = '" + FromAreaTwo + "',[RiteVehicleTwo] = '" + RiteVehicleTwo + "',[ArrivalAreaTwo] = '" + ArrivalAreaTwo + "',[ReceiveArea] = '" + ReceiveArea + "',[AccompanyFugle] = '" + AccompanyFugl + "',[MoveDate] = '" + MoveDate + "',[AccompanyPeo] = '" + AccompanyPeo + "',[GuardCuston] = '" + GuardCuston + "',[Principal] = '" + Principal + "',[Roster] = '" + Roster + "',[Perform]= '" + Perform + "',[Remark] = '" + Remark + "',[ModifiedBy] = '" + ModifiedBy + "',[ModifiedDate] = getdate() WHERE Order_ID = '" + ViewState["Order_ID"].ToString() + "'"; try { db.executeUpdate(Update); WebWindow.alert("修改成功"); } catch (Exception er) { WebWindow.alert(er.Message); } } } }
//保存当前题并装载上一题的方法 private void selectExmQuestioPrev(string Answer) { //保存当前题目 string sqlOk = "update temp" + config.Staff.Username + " set QuestionState= '" + hfdState.Value + "',Answer='" + Answer + "' where Question_Id='" + lblQuestionId.Text + "'"; db = new MDataBase(config.DBConn); db.executeUpdate(sqlOk); //装载下一题 string sql = "select a.Question_Id,a.Question,a.Question_Guid,b.AnswerA,b.AnswerB,b.AnswerC,b.AnswerD,b.AnswerE,a.Answer from temp" + config.Staff.Username + " a,SExmQuestion b where a.Question_Guid=b.Question_Guid and a.Question_Id='" + Convert.ToString(Convert.ToInt32(lblQuestionId.Text) - 1) + "'"; DataRow drQuestion; db = new MDataBase(config.DBConn); bool blnRtnCode = db.GetDataRow(sql, out drQuestion); if (blnRtnCode == false || drQuestion == null) { // 错误 return; } //赋值 this.lblQuestionId.Text = drQuestion["Question_Id"].ToString(); this.lblQuestion.Text = drQuestion["Question"].ToString(); this.lblAnwerA.Text = drQuestion["AnswerA"].ToString(); this.lblAnwerB.Text = drQuestion["AnswerB"].ToString(); this.lblAnwerC.Text = drQuestion["AnswerC"].ToString(); this.lblAnswer.Text = drQuestion["Answer"].ToString(); hfdQuestionGuid.Value = drQuestion["Question_Guid"].ToString(); //如果答案里包括A,chkAnswerA钩上 if (lblAnswer.Text.IndexOf("A") != -1) { chkAnswerA.Checked = true; } //如果答案里包括B,chkAnswerB钩上 if (lblAnswer.Text.IndexOf("B") != -1) { chkAnswerB.Checked = true; } //如果答案里包括C,chkAnswerC钩上 if (lblAnswer.Text.IndexOf("C") != -1) { chkAnswerC.Checked = true; } //如果答案里包括D,chkAnswerD钩上 if (lblAnswer.Text.IndexOf("D") != -1) { chkAnswerD.Checked = true; } //如果答案里包括E,chkAnswerE钩上 if (lblAnswer.Text.IndexOf("E") != -1) { chkAnswerE.Checked = true; } //如果D答案为空,选项框隐藏 if (drQuestion["AnswerD"].ToString() != "") { chkAnswerD.Visible = true; this.lblAnwerD.Text = drQuestion["AnswerD"].ToString(); } else { lblAnwerD.Text = ""; chkAnswerD.Visible = false; } //如果E答案为空,选项框隐藏 if (drQuestion["AnswerE"].ToString() != "") { chkAnswerE.Visible = true; this.lblAnwerE.Text = drQuestion["AnswerE"].ToString(); } else { lblAnwerE.Text = ""; chkAnswerE.Visible = false; } }
/// <summary> /// SExmExam对象Update方法 /// </summary> private bool executeUpdate() { bool blnFirstField = true; string sql = "update SExmExam set "; string sqlPK = " where "; // (Exam_Id)字段 sqlPK += "Exam_Id = '" + _Exam_Id + "'"; // (ExamName)字段 if (_blnExamNameChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "ExamName = '" + _ExamName + "'"; } // (ScoreType)字段 if (_blnScoreTypeChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "ScoreType = " + _ScoreType.ToString(); } // (BeginTime)字段 if (_blnBeginTimeChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "BeginTime = '" + _BeginTime.ToString() + "'"; } // (EndTime)字段 if (_blnEndTimeChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "EndTime = '" + _EndTime.ToString() + "'"; } // (Times)字段 if (_blnTimesChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "Times = " + _Times.ToString(); } // (Count)字段 if (_blnCountChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "Count = " + _Count.ToString(); } // (ExamEmploees)字段 if (_blnExamEmploeesChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "ExamEmploees = " + _ExamEmploees.ToString(); } // (Average)字段 if (_blnAverageChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "Average = " + _Average.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); } }
protected void btnSave_Click(object sender, EventArgs e) { if (drpOrder_ID.SelectedValue == "0") { WebWindow.alert("请选择要操作的勤务的编号"); return; } string Order_ID = drpOrder_ID.SelectedValue.ToString(); string NJGuard = Getstring(Chknj1, Chknj2, Chknj3, Chknj4, Chknj5, Chknj6, Chknj7, Chknj8, Chknj9, Chknj10, Chknj11, Chknj12); string XVGuard = Getstring(Chkxz1, Chkxz2, Chkxz3, Chkxz4, Chkxz5, Chkxz6, Chkxz7, Chkxz8, Chkxz9, Chkxz10, Chkxz11, Chkxz12); string WXGuard = Getstring(Chkwx1, Chkwx2, Chkwx3, Chkwx4, Chkwx5, Chkwx6, Chkwx7, Chkwx8, Chkwx9, Chkwx10, Chkwx11, Chkwx12); string CZGuard = Getstring(Chkcz1, Chkcz2, Chkcz3, Chkcz4, Chkcz5, Chkcz6, Chkcz7, Chkcz8, Chkcz9, Chkcz10, Chkcz11, Chkcz12); string SZGuard = Getstring(Chksz1, Chksz2, Chksz3, Chksz4, Chksz5, Chksz6, Chksz7, Chksz8, Chksz9, Chksz10, Chksz11, Chksz12); string NTGuard = Getstring(Chknt1, Chknt2, Chknt3, Chknt4, Chknt5, Chknt6, Chknt7, Chknt8, Chknt9, Chknt10, Chknt11, Chknt12); string LYGGuard = Getstring(Chklyg1, Chklyg2, Chklyg3, Chklyg4, Chklyg5, Chklyg6, Chklyg7, Chklyg8, Chklyg9, Chklyg10, Chklyg11, Chklyg12); string HAGuard = Getstring(Chkha1, Chkha2, Chkha3, Chkha4, Chkha5, Chkha6, Chkha7, Chkha8, Chkha9, Chkha10, Chkha11, Chkha12); string ZJGuard = Getstring(Chkzj1, Chkzj2, Chkzj3, Chkzj4, Chkzj5, Chkzj6, Chkzj7, Chkzj8, Chkzj9, Chkzj10, Chkzj11, Chkzj12); string TZGuard = Getstring(Chktz1, Chktz2, Chktz3, Chktz4, Chktz5, Chktz6, Chktz7, Chktz8, Chktz9, Chktz10, Chktz11, Chktz12); string SQGuard = Getstring(Chksq1, Chksq2, Chksq3, Chksq4, Chksq5, Chksq6, Chksq7, Chksq8, Chksq9, Chksq10, Chksq11, Chksq12); string YCGuard = Getstring(Chkyc1, Chkyc2, Chkyc3, Chkyc4, Chkyc5, Chkyc6, Chkyc7, Chkyc8, Chkyc9, Chkyc10, Chkyc11, Chkyc12); string YZGuard = Getstring(Chkyz1, Chkyz2, Chkyz3, Chkyz4, Chkyz5, Chkyz6, Chkyz7, Chkyz8, Chkyz9, Chkyz10, Chkyz11, Chkyz12); string Remark = this.TextBox1.Text.Trim(); string CreatedBy = ""; if (ViewState["State"].ToString() == "Insert") { string Insert = "INSERT INTO SOrdSummarize([Order_ID] ,[NJGuard] ,[XVGuard],[WXGuard],[CZGuard],[SZGuard],[NTGuard],[LYGGuard]," + "[HAGuard],[ZJGuard],[TZGuard],[SQGuard],[YCGuard], [YZGuard],[Remark],[CreatedBy],[CreatedDate] " + " ) VALUES ('" + Order_ID + "','" + NJGuard + "','" + XVGuard + "','" + WXGuard + "','" + CZGuard + "','" + SZGuard + "','" + NTGuard + "','" + LYGGuard + "','" + HAGuard + "','" + ZJGuard + "','" + TZGuard + "','" + SQGuard + "','" + YCGuard + "','" + YZGuard + "','" + Remark + "','" + CreatedBy + "',getdate())"; try { db.executeInsert(Insert); WebWindow.alert("保存成功"); } catch (Exception er) { WebWindow.alert(er.Message); } } else if (ViewState["State"].ToString() == "Update") { string update = "UPDATE SOrdSummarize set " + " [NJGuard] = '" + NJGuard + "'," + " [XVGuard] = '" + XVGuard + "'," + " [WXGuard] = '" + WXGuard + "'," + " [CZGuard] = '" + CZGuard + "'," + " [SZGuard] = '" + SZGuard + "'," + " [NTGuard] = '" + NTGuard + "'," + " [LYGGuard] = '" + LYGGuard + "'," + " [HAGuard] = '" + HAGuard + "'," + " [ZJGuard] = '" + ZJGuard + "'," + " [TZGuard] = '" + TZGuard + "'," + " [SQGuard] = '" + SQGuard + "'," + " [YCGuard] = '" + YCGuard + "'," + " [YZGuard] = '" + YZGuard + "'," + " [Remark] = '" + Remark + "'," + " [ModifiedBy] = '" + CreatedBy + "'," + " [ModifiedDate] = getdate() WHERE Order_ID = '" + drpOrder_ID.SelectedValue.ToString() + "'"; try { db.executeUpdate(update); WebWindow.alert("修改成功"); } catch (Exception er) { WebWindow.alert(er.Message); } } }
protected void BtnSave_Click(object sender, EventArgs e) { if (drpOrder_ID.SelectedValue == "0") { WebWindow.alert("请选择要操作的勤务的编号"); return; } string Order_ID = drpOrder_ID.SelectedValue; //勤务编号 string EnregisterTime = this.lblEnregisterTime.Text.Trim(); string GuardSpec = drpGuardSpec.SelectedValue; //警卫规格: string MoveDate = txtMoveDate.Text.Trim(); try { Convert.ToInt32(MoveDate); } catch { WebWindow.alert("抵达天数请输入日期型"); return; } if (txtMoveTomeFrom3.Text == "") { txtMoveTomeFrom3.Text = "00"; } string MoveTomeFrom = txtMoveTomeFrom1.Text.Trim() + " " + drpMoveTomeFrom2.Text.Trim() + ":" + txtMoveTomeFrom3.Text.Trim() + ":00"; //日期加小时加分秒 try { Convert.ToDateTime(MoveTomeFrom); } catch { WebWindow.alert("活动日期从请输入日期型"); return; } if (txtMoveTomeTo3.Text == "") { txtMoveTomeTo3.Text = "00"; } string MoveTomeTo = txtMoveTomeTo1.Text.Trim() + " " + drpMoveTomeTo2.Text.Trim() + ":" + txtMoveTomeTo3.Text.Trim() + ":00"; //日期加小时加分秒 try { Convert.ToDateTime(MoveTomeTo); } catch { WebWindow.alert("活动日期从请输入日期型"); return; } string FrontUnit = txtFrontUnit.Text.Trim(); // 主持或主办单位: string AppearedFugle = txtAppearedFugle.Text.Trim(); // 出席的主要领导: string CalendarArrange = txtCalendarArrange.Text.Trim(); // 活动日程 string Principal = txtPrincipal.Text.Trim(); // 负责人: string Roster = txtRoster.Text.Trim(); // 值勤人员: string Perform = txtPerform.Text.Trim(); string Remark = txtRemark.Text.Trim(); // 备注: string CreatedBy = txtCreatedBy.Text.Trim(); // 填表人: if (ViewState["State"] == null || ViewState["State"].ToString() == null) { Response.Redirect("error2.htm"); } else { if (ViewState["State"].ToString() == "Insert") { string Insert = "INSERT INTO SOrdSynodBenregister([Order_ID],[EnregisterTime],[GuardSpec] ,[MoveDate] ,[MoveTomeFrom] ,[MoveTomeTo], " + " [FrontUnit] ,[AppearedFugle] ,[CalendarArrange] ,[Principal] ,[Roster] ,[Remark] ,[Perform],[CreatedBy] ," + " [CreatedDate]) VALUES('" + Order_ID + "','" + EnregisterTime + "','" + GuardSpec + "','" + MoveDate + "','" + MoveTomeFrom + "','" + MoveTomeTo + "','" + FrontUnit + "','" + AppearedFugle + "','" + CalendarArrange + "','" + Principal + "','" + Roster + "','" + Remark + "','" + Perform + "','" + CreatedBy + "',getdate()) "; try { db.executeInsert(Insert); WebWindow.alert("保存成功"); } catch (Exception er) { WebWindow.alert(er.Message); } } else if (ViewState["State"].ToString() == "Update") { if (ViewState["Order_ID"] == null || ViewState["Order_ID"].ToString() == "") { Response.Redirect("error2.htm"); } string ModifiedBy = ""; string Update = "UPDATE SOrdSynodBenregister set " + "[EnregisterTime] = '" + EnregisterTime + "'," + "[GuardSpec] = '" + GuardSpec + "'," + "[MoveDate] = '" + MoveDate + "'," + "[MoveTomeFrom] = '" + MoveTomeFrom + "'," + "[MoveTomeTo] = '" + MoveTomeTo + "'," + "[FrontUnit] = '" + FrontUnit + "'," + "[AppearedFugle] = '" + AppearedFugle + "'," + "[CalendarArrange] = '" + CalendarArrange + "'," + "[Principal] = '" + Principal + "'," + "[Roster] = '" + Roster + "'," + "[Remark] = '" + Remark + "'," + "[Perform] = '" + Perform + "'," + "[ModifiedBy] = '" + ModifiedBy + "'," + "[ModifiedDate] = getdate() WHERE Order_ID = '" + Order_ID + "'"; try { db.executeUpdate(Update); WebWindow.alert("修改成功"); } catch (Exception er) { WebWindow.alert(er.Message); } } } }
/// <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> /// SPsnWorkTime对象Update方法 /// </summary> private bool executeUpdate() { bool blnFirstField = true; string sql = "update SPsnWorkTime set "; string sqlPK = " where "; // (WorkTime_Guid)字段 sqlPK += "WorkTime_Guid = '" + _WorkTime_Guid + "'"; // (Staff_Id)字段 if (_blnStaff_IdChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "Staff_Id = '" + _Staff_Id + "'"; } // (Day)字段 if (_blnDayChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "Day = '" + _Day.ToString() + "'"; } // (WorkStatusId)字段 if (_blnWorkStatusIdChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "WorkStatusId = " + _WorkStatusId.ToString(); } // (Job)字段 if (_blnJobChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "Job = '" + _Job + "'"; } // (Address)字段 if (_blnAddressChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "Address = '" + _Address + "'"; } // (Remark)字段 if (_blnRemarkChanged == true) { if (blnFirstField == true) { blnFirstField = false; } else { sql += ","; } sql += "Remark = '" + _Remark + "'"; } // (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> /// 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); } }
private string SaveNet(string Personnel) { if (drpOrder_ID.SelectedValue == "0") { return("请选择要操作的勤务的编号"); } string Net_Guid = Guid.NewGuid().ToString(); if (ViewState["Net_Guid"] == null || ViewState["Net_Guid"].ToString() == "") { ViewState["Net_Guid"] = Net_Guid; //得到编号 } string Title = this.txtTitle.Text.Trim(); //标题 string Net = ""; if (CheckNet1.Checked == true) { Net = "八局网站"; } else if (CheckNet2.Checked == true) { Net = "省厅网站"; } else if (CheckNet3.Checked == true) { Net = "省局网站"; } string Type = ""; if (radType1.Checked == true) { Type = "发布栏目"; } else if (radType2.Checked == true) { Type = "发布子栏目"; } else if (radType3.Checked == true) { Type = "勤务信息"; } else if (radType4.Checked == true) { Type = "现场勤务"; } string Unit1 = this.txtUnit.Text.Trim(); //单位 string Content = this.txtContent.Text.Trim(); //内容 string Man = ""; //得到当前的用户名ID string Time = this.lblTime.Text.Trim(); //时间 string Adjunct = ""; if (ViewState["AttachmentBatch_Guid"] == null || ViewState["AttachmentBatch_Guid"].ToString() == "") { } else { Adjunct = ViewState["AttachmentBatch_Guid"].ToString(); //要改的 } if (ViewState["State"].ToString() == "Insert") { { string Insert = "INSERT INTO SOrdNet([Order_ID],[Net_Guid],[Title],[Net],[Type],[Content],[Unit],[Man] ,[Time] ,[Adjunct] ,[CreatedBy]," + "[CreatedDate] ,[StatusId] ) VALUES ('" + drpOrder_ID.SelectedValue + "','" + ViewState["Net_Guid"].ToString() + "','" + Title + "','" + Net + "','" + Type + "','" + Content + "','" + Unit1 + "','" + ViewState["Satff_Id"].ToString() + "','" + Time + "','" + Adjunct + "','" + ViewState["Satff_Id"].ToString() + "',getdate(),1)"; try { db.executeInsert(Insert); return("保存成功"); } catch (Exception er) { return(er.Message); } } } else if (ViewState["State"].ToString() == "Update") { string Update = "UPDATE SOrdNet set " + "[Net_Guid] = '" + Net_Guid + "'," + "[Title] = '" + Title + "'," + "[Net] = '" + Net + "'," + "[Type] = '" + Type + "'," + "[Content] = '" + Content + "'," + "[Unit] = '" + Unit1 + "'," + "[Man] = '" + Man + "'," + "[Time] = '" + Time + "'," + "[Adjunct] = '" + Adjunct + "'," + "[Personnel] = '" + Personnel + "'," + "[ModifiedBy] = '" + ViewState["Satff_Id"].ToString() + "'," + "[ModifiedDate] = getdate() WHERE Order_ID = '" + ViewState["Order_ID"].ToString() + "'"; try { db.executeUpdate(Update); return("修改成功"); } catch (Exception er) { return(er.Message); } } return(""); }
/// <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); }