| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  | using BLL; | 
					
						
							| 
									
										
										
										
											2024-01-17 16:12:42 +08:00
										 |  |  |  | using Newtonsoft.Json.Linq; | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  | using System; | 
					
						
							| 
									
										
										
										
											2024-01-17 16:12:42 +08:00
										 |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using System.Data; | 
					
						
							|  |  |  |  | using System.Data.SqlClient; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							| 
									
										
										
										
											2024-01-24 09:17:17 +08:00
										 |  |  |  | using AspNet = System.Web.UI.WebControls; | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace FineUIPro.Web.TestRun.DriverPrepare | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public partial class DutyEdit : PageBase | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         #region 加载 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 页面加载 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void Page_Load(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (!IsPostBack) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 string id = Request.Params["id"]; | 
					
						
							|  |  |  |  |                 if (!string.IsNullOrEmpty(id)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2024-01-17 16:12:42 +08:00
										 |  |  |  |                     BindGrid(); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     var list = DriverPrepareDutyItemService.GetLists("Empty"); | 
					
						
							|  |  |  |  |                     if (list.Count == 0) | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |                     { | 
					
						
							| 
									
										
										
										
											2024-01-17 16:12:42 +08:00
										 |  |  |  |                         DriverPrepareDutyItemService.CreateDutyItems(); | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |                     } | 
					
						
							| 
									
										
										
										
											2024-01-17 16:12:42 +08:00
										 |  |  |  |                     BindGrid(); | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2024-01-24 09:17:17 +08:00
										 |  |  |  |                 //Grid1.EnableCheckBoxSelect = true; | 
					
						
							|  |  |  |  |                 //Grid1.CheckBoxSelectOnly = true; | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-17 16:12:42 +08:00
										 |  |  |  |         #region 数据绑定 | 
					
						
							|  |  |  |  |         //加载列表 | 
					
						
							|  |  |  |  |         public void BindGrid() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             string strSql = @"select * from DriverPrepare_DutyItem chec" | 
					
						
							|  |  |  |  |                             + @" where chec.DutyId=@DutyId"; | 
					
						
							|  |  |  |  |             List<SqlParameter> listStr = new List<SqlParameter>(); | 
					
						
							|  |  |  |  |             string id = "Empty"; | 
					
						
							|  |  |  |  |             if (!string.IsNullOrEmpty(Request.Params["id"])) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 id = Request.Params["id"]; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             listStr.Add(new SqlParameter("@DutyId", id)); | 
					
						
							|  |  |  |  |             SqlParameter[] parameter = listStr.ToArray(); | 
					
						
							|  |  |  |  |             DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); | 
					
						
							|  |  |  |  |             Grid1.RecordCount = tb.Rows.Count; | 
					
						
							|  |  |  |  |             //tb = GetFilteredTable(Grid1.FilteredData, tb); | 
					
						
							|  |  |  |  |             var table = this.GetPagedDataTable(Grid1, tb); | 
					
						
							|  |  |  |  |             Grid1.DataSource = table; | 
					
						
							|  |  |  |  |             Grid1.DataBind(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 排序 | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         /// <summary> | 
					
						
							| 
									
										
										
										
											2024-01-17 16:12:42 +08:00
										 |  |  |  |         /// 排序 | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							| 
									
										
										
										
											2024-01-17 16:12:42 +08:00
										 |  |  |  |         protected void Grid1_Sort(object sender, GridSortEventArgs e) | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2024-01-17 16:12:42 +08:00
										 |  |  |  |             this.BindGrid(); | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 保存 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 保存按钮 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void btnSave_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             string id = Request.Params["id"]; | 
					
						
							|  |  |  |  |             Model.DriverPrepare_Duty newData = new Model.DriverPrepare_Duty(); | 
					
						
							| 
									
										
										
										
											2024-01-17 16:12:42 +08:00
										 |  |  |  |             newData.CompileMan = this.CurrUser.UserId; | 
					
						
							|  |  |  |  |             newData.CompileDate = DateTime.Now; | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |             newData.ProjectId = this.CurrUser.LoginProjectId; | 
					
						
							|  |  |  |  |             if (!string.IsNullOrEmpty(id)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 newData.DutyId = id; | 
					
						
							|  |  |  |  |                 BLL.DriverPrepareDutyService.UpdateDriverPrepareDriverPlan(newData); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2024-01-17 16:12:42 +08:00
										 |  |  |  |                 newData.DutyId = SQLHelper.GetNewID(typeof(Model.DriverPrepare_Duty)); | 
					
						
							|  |  |  |  |                 BLL.DriverPrepareDutyService.AddDriverPrepareDriverPlan(newData); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             CheckBoxField Item1 = (CheckBoxField)Grid1.FindColumn("Item1"); | 
					
						
							|  |  |  |  |             CheckBoxField Item2 = (CheckBoxField)Grid1.FindColumn("Item2"); | 
					
						
							|  |  |  |  |             CheckBoxField Item3 = (CheckBoxField)Grid1.FindColumn("Item3"); | 
					
						
							|  |  |  |  |             CheckBoxField Item4 = (CheckBoxField)Grid1.FindColumn("Item4"); | 
					
						
							|  |  |  |  |             CheckBoxField Item5 = (CheckBoxField)Grid1.FindColumn("Item5"); | 
					
						
							|  |  |  |  |             CheckBoxField Item6 = (CheckBoxField)Grid1.FindColumn("Item6"); | 
					
						
							|  |  |  |  |             CheckBoxField Item7 = (CheckBoxField)Grid1.FindColumn("Item7"); | 
					
						
							|  |  |  |  |             CheckBoxField Item8 = (CheckBoxField)Grid1.FindColumn("Item8"); | 
					
						
							|  |  |  |  |             CheckBoxField Item9 = (CheckBoxField)Grid1.FindColumn("Item9"); | 
					
						
							|  |  |  |  |             CheckBoxField Item10 = (CheckBoxField)Grid1.FindColumn("Item10"); | 
					
						
							|  |  |  |  |             CheckBoxField Item11 = (CheckBoxField)Grid1.FindColumn("Item11"); | 
					
						
							|  |  |  |  |             CheckBoxField Item12 = (CheckBoxField)Grid1.FindColumn("Item12"); | 
					
						
							|  |  |  |  |             CheckBoxField Item13 = (CheckBoxField)Grid1.FindColumn("Item13"); | 
					
						
							|  |  |  |  |             CheckBoxField Item14 = (CheckBoxField)Grid1.FindColumn("Item14"); | 
					
						
							|  |  |  |  |             if (string.IsNullOrEmpty(id)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 id = "Empty"; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             var list = DriverPrepareDutyItemService.GetLists(id); | 
					
						
							|  |  |  |  |             foreach (JObject mergedRow in Grid1.GetMergedData()) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 int i = mergedRow.Value<int>("index"); | 
					
						
							|  |  |  |  |                 var item = list.FirstOrDefault(x => x.DutyItemId == Grid1.Rows[i].RowID); | 
					
						
							|  |  |  |  |                 JObject values = mergedRow.Value<JObject>("values"); | 
					
						
							|  |  |  |  |                 if (item != null) | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2024-01-17 16:12:42 +08:00
										 |  |  |  |                     item.DutyId = newData.DutyId; | 
					
						
							|  |  |  |  |                     item.Item1 = Item1.GetCheckedState(i); | 
					
						
							|  |  |  |  |                     item.Item2 = Item2.GetCheckedState(i); | 
					
						
							|  |  |  |  |                     item.Item3 = Item3.GetCheckedState(i); | 
					
						
							|  |  |  |  |                     item.Item4 = Item4.GetCheckedState(i); | 
					
						
							|  |  |  |  |                     item.Item5 = Item5.GetCheckedState(i); | 
					
						
							|  |  |  |  |                     item.Item6 = Item6.GetCheckedState(i); | 
					
						
							|  |  |  |  |                     item.Item7 = Item7.GetCheckedState(i); | 
					
						
							|  |  |  |  |                     item.Item8 = Item8.GetCheckedState(i); | 
					
						
							|  |  |  |  |                     item.Item9 = Item9.GetCheckedState(i); | 
					
						
							|  |  |  |  |                     item.Item10 = Item10.GetCheckedState(i); | 
					
						
							|  |  |  |  |                     item.Item11 = Item11.GetCheckedState(i); | 
					
						
							|  |  |  |  |                     item.Item12 = Item12.GetCheckedState(i); | 
					
						
							|  |  |  |  |                     item.Item13 = Item13.GetCheckedState(i); | 
					
						
							|  |  |  |  |                     item.Item14 = Item14.GetCheckedState(i); | 
					
						
							|  |  |  |  |                     item.Remark = values.Value<string>("Remark"); | 
					
						
							|  |  |  |  |                     BLL.DriverPrepareDutyItemService.UpdateDutyItem(item); | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2024-01-24 09:17:17 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |             //int rowsCount = this.Grid1.Rows.Count; | 
					
						
							|  |  |  |  |             //foreach (JObject mergedRow in Grid1.GetMergedData()) | 
					
						
							|  |  |  |  |             //{ | 
					
						
							|  |  |  |  |             //    int i = mergedRow.Value<int>("index"); | 
					
						
							|  |  |  |  |             //    var item = list.FirstOrDefault(x => x.DutyItemId == Grid1.Rows[i].RowID); | 
					
						
							|  |  |  |  |             //    JObject values = mergedRow.Value<JObject>("values"); | 
					
						
							|  |  |  |  |             //    AspNet.CheckBox cbItem1 = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbItem1")); | 
					
						
							|  |  |  |  |             //    AspNet.CheckBox cbItem2 = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbItem2")); | 
					
						
							|  |  |  |  |             //    AspNet.CheckBox cbItem3 = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbItem3")); | 
					
						
							|  |  |  |  |             //    AspNet.CheckBox cbItem4 = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbItem4")); | 
					
						
							|  |  |  |  |             //    AspNet.CheckBox cbItem5 = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbItem5")); | 
					
						
							|  |  |  |  |             //    AspNet.CheckBox cbItem6 = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbItem6")); | 
					
						
							|  |  |  |  |             //    AspNet.CheckBox cbItem7 = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbItem7")); | 
					
						
							|  |  |  |  |             //    AspNet.CheckBox cbItem8 = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbItem8")); | 
					
						
							|  |  |  |  |             //    AspNet.CheckBox cbItem9 = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbItem9")); | 
					
						
							|  |  |  |  |             //    AspNet.CheckBox cbItem10 = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbItem10")); | 
					
						
							|  |  |  |  |             //    AspNet.CheckBox cbItem11 = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbItem11")); | 
					
						
							|  |  |  |  |             //    AspNet.CheckBox cbItem12 = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbItem12")); | 
					
						
							|  |  |  |  |             //    AspNet.CheckBox cbItem13 = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbItem13")); | 
					
						
							|  |  |  |  |             //    AspNet.CheckBox cbItem14 = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbItem14")); | 
					
						
							|  |  |  |  |             //    item.Item1 = cbItem1.Checked; | 
					
						
							|  |  |  |  |             //    item.Item2 = cbItem2.Checked; | 
					
						
							|  |  |  |  |             //    item.Item3 = cbItem3.Checked; | 
					
						
							|  |  |  |  |             //    item.Item4 = cbItem4.Checked; | 
					
						
							|  |  |  |  |             //    item.Item5 = cbItem5.Checked; | 
					
						
							|  |  |  |  |             //    item.Item6 = cbItem6.Checked; | 
					
						
							|  |  |  |  |             //    item.Item7 = cbItem7.Checked; | 
					
						
							|  |  |  |  |             //    item.Item8 = cbItem8.Checked; | 
					
						
							|  |  |  |  |             //    item.Item9 = cbItem9.Checked; | 
					
						
							|  |  |  |  |             //    item.Item10 = cbItem10.Checked; | 
					
						
							|  |  |  |  |             //    item.Item11 = cbItem11.Checked; | 
					
						
							|  |  |  |  |             //    item.Item12 = cbItem12.Checked; | 
					
						
							|  |  |  |  |             //    item.Item13 = cbItem13.Checked; | 
					
						
							|  |  |  |  |             //    item.Item14 = cbItem14.Checked; | 
					
						
							|  |  |  |  |             //    item.Remark = values.Value<string>("Remark"); | 
					
						
							|  |  |  |  |             //    BLL.DriverPrepareDutyItemService.UpdateDutyItem(item); | 
					
						
							|  |  |  |  |             //} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |             ShowNotify("保存成功!", MessageBoxIcon.Success); | 
					
						
							|  |  |  |  |             PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							| 
									
										
										
										
											2024-01-17 16:12:42 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         protected void Button1_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             CheckBoxField field1 = (CheckBoxField)Grid1.FindColumn("CheckBoxField1"); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             int selectedCount = Grid1.SelectedRowIndexArray.Length; | 
					
						
							|  |  |  |  |             //if (selectedCount > 0) | 
					
						
							|  |  |  |  |             //{ | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //    for (int i = 0; i < selectedCount; i++) | 
					
						
							|  |  |  |  |             //    { | 
					
						
							|  |  |  |  |             //        int rowIndex = Grid1.SelectedRowIndexArray[i]; | 
					
						
							|  |  |  |  |             //        sb.Append("<tr>"); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //        sb.AppendFormat("<td>{0}</td>", rowIndex + 1); | 
					
						
							|  |  |  |  |             //        sb.AppendFormat("<td>{0}</td>", field1.GetCheckedState(rowIndex)); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //        sb.Append("</tr>"); | 
					
						
							|  |  |  |  |             //    } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //    sb.Append("</table>"); | 
					
						
							|  |  |  |  |             //} | 
					
						
							|  |  |  |  |             //else | 
					
						
							|  |  |  |  |             //{ | 
					
						
							|  |  |  |  |             //    sb.Append("<strong>没有选中任何一行!</strong>"); | 
					
						
							|  |  |  |  |             //} | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | } |