protected void Button1_Click(object sender, EventArgs e) { WX.Main.CurUser.LoadUserModel(false); WX.WorkOrder.Order.MODEL porder = WX.WorkOrder.Order.NewDataModel(Request["OrderID"]); WX.WorkOrder.Order.MODEL order = WX.WorkOrder.Order.NewDataModel(); if (Request["POrderID"] != null && Request["POrderID"] != "") { order = WX.WorkOrder.Order.NewDataModel(Request["POrderID"]); } else { order.ExecUserID.value = Request["UserID"]; order.PID.value = Request["OrderID"]; } order.DeptWorkID.value = WX.Main.CurUser.UserModel.DepartmentID.value; order.UserID.value = porder.UserID.value; order.AssignUserID.value = WX.Main.CurUser.UserID; order.Remarks.value = Remarks_txt.Text; order.Title.value = Title_txt.Text; order.Proj.value = porder.Proj.value; order.Type.value = porder.Type.value; order.Count.value = Count_txt.Text; order.State.value = 3; order.YJTime.value = YJTime_txt.Text; order.StateTime.value = DateTime.Now; if (Request["POrderID"] != null && Request["POrderID"] != "") { order.Update(); } else { order.Insert(); } if (porder.State.ToInt32() < 2) { porder.State.value = 2; porder.Update(); } Response.Redirect("WorkOrder_Fenpei.aspx?OrderID=" + Request["OrderID"]); }
private void EditOrder(int state) { WX.WorkOrder.Order.MODEL order = WX.WorkOrder.Order.NewDataModel(); if (Request["OrderID"] != null && Request["OrderID"] != "") { order = WX.WorkOrder.Order.NewDataModel(Request["OrderID"]); } order.UserID.value = this.CurUser.UserID; order.Remarks.value = Remarks_txt.Text; order.Title.value = Title_txt.Text; order.Proj.value = Proj_drop.SelectedValue; order.Type.value = Type_drop.SelectedValue; order.State.value = state; if (state == 1) { order.SubTime.value = DateTime.Now; } if (YJTime_txt.Text.Trim() != "") { order.YJTime.value = YJTime_txt.Text; } order.StateTime.value = DateTime.Now; int id = 0; if (otherDept.SelectedValue == "-1") { order.DeptWorkID.value = -1; } if (Request["OrderID"] != null && Request["OrderID"] != "") { id = order.ID.ToInt32(); order.Update(); //WX.Main.ExecuteDelete("WorkOrder_Dept", "WID", id.ToString()); } else { id = order.Insert(true); } WX.WorkOrder.Dept.MODEL dept; if (otherDept.SelectedValue == "-1") { WX.Main.ExecuteDelete("WorkOrder_Orders", "PID", id.ToString()); this.CurUser.LoadUserModel(false); if (!(Request["OrderID"] != null && Request["OrderID"] != "")) { dept = WX.WorkOrder.Dept.NewDataModel(); dept.WID.value = id; dept.DeptID.value = this.CurUser.UserModel.DepartmentID.ToString(); if (state == 1) { dept.SubTime.value = DateTime.Now; } dept.Insert(); } else { dept = WX.WorkOrder.Dept.GetModel("select * from WorkOrder_Dept where WID=" + id + " and DeptID=" + this.CurUser.UserModel.DepartmentID.value); if (state == 1 && dept.SubTime.ToString() == "") { dept.SubTime.value = DateTime.Now; dept.Update(); } } WX.WorkOrder.Order.MODEL corder; for (int i = 0; i < DataList2.Items.Count; i++) { corder = WX.WorkOrder.Order.NewDataModel(); CheckBox cbox = (CheckBox)DataList2.Items[i].FindControl("CheckBox1"); HiddenField hf = (HiddenField)DataList2.Items[i].FindControl("HiddenField1"); TextBox tbox = (TextBox)DataList2.Items[i].FindControl("TextBox1"); if (cbox.Checked) { corder.PID.value = id; corder.DeptWorkID.value = this.CurUser.UserModel.DepartmentID.value; corder.UserID.value = order.UserID.value; corder.AssignUserID.value = this.CurUser.UserID; corder.ExecUserID.value = cbox.ToolTip; corder.Remarks.value = order.Remarks.ToString(); corder.Title.value = order.Title.ToString(); corder.Proj.value = order.Proj.value; corder.Type.value = order.Type.value; corder.Count.value = IsNUM(tbox.Text); corder.State.value = 3; if (state == 1) { corder.SubTime.value = DateTime.Now; } if (order.YJTime.ToString() != "") { corder.YJTime.value = order.YJTime.value; } corder.StateTime.value = DateTime.Now; corder.Insert(); } } } else { WX.Main.ExecuteDelete("WorkOrder_Dept", "WID", id.ToString()); for (int i = 0; i < Dept_check.Items.Count; i++) { if (Dept_check.Items[i].Selected) { dept = WX.WorkOrder.Dept.NewDataModel(); dept.WID.value = id; dept.DeptID.value = Dept_check.Items[i].Value; if (state == 1) { dept.SubTime.value = DateTime.Now; } dept.Insert(); } } } Response.Redirect("WorkOrder_List.aspx"); }