//任务预算编制更新 public void Repeater1_ItemCommand(object sender, RepeaterCommandEventArgs e) { if (e.CommandName == "change") { // string task_code = ((LinkButton)sender).CommandArgument + "";//获取传递的任务号 string task_code = e.CommandArgument + ""; List <string> listsql = new List <string>(); //listsql.Add(string.Format("DELETE FROM dbo.YS_TASK_BUDGET WHERE task_code='{0}';", tsaId));//删除任务预算表内的信息 listsql.Add(string.Format("DELETE FROM dbo.YS_MATERIAL_HISTORY_INFO WHERE task_code='{0}';", task_code)); //删除历史表内的信息 //listsql.Add(string.Format("DELETE FROM dbo.YS_NODE_INSTANCE WHERE task_code='{0}';", tsaId));//删除node实例表中的信息 listsql.Add(getInsertIntoHistoryInfoTableSqltext(task_code)); //向历史表重新插入信息 // listsql.Add(getInsertIntoTaskBudgetTableSqltext(tsaId));//向任务预算表重新插入信息 //listsql.Add(string.Format("UPDATE dbo.TBPM_TCTSASSGN SET TSA_BUDGET_DATETIME=GETDATE() WHERE TSA_ID='{0}';", tsaId));//更新任务表中预算提交的时间 //DBCallCommon.ExecuteTrans(listsql); //listsql.Clear(); //string[] ids = new string[] { ConfigurationSettings.AppSettings["BudgetEditorId"] };//配置文件中读取预算编制人id //BudgetFlowEngine.activeFollowNode(tsaId, "0", ids);//向node实例表中插入第一个实例 //更新任务预算表 string sqlText = " SELECT TOP 1 '" + task_code + "', CM_CONTR, CM_PROJ , TSA_ENGNAME ,( SELECT BM_TUTOTALWGHT FROM TBPM_STRINFODQO WHERE BM_ZONGXU='1' AND BM_ENGID='" + task_code + "'), ( SELECT ISNULL(SUM(c_total_cost),0) FROM dbo.YS_MATERIAL_HISTORY_INFO WHERE task_code='" + task_code + "' AND material_code LIKE '01.07%'),( SELECT ISNULL(SUM(c_total_cost),0) FROM dbo.YS_MATERIAL_HISTORY_INFO WHERE task_code='" + task_code + "' AND material_code LIKE '01.11%'),( SELECT ISNULL(SUM(c_total_cost),0) FROM dbo.YS_MATERIAL_HISTORY_INFO WHERE task_code='" + task_code + "' AND material_code LIKE '01.15%'),( SELECT ISNULL(SUM(c_total_cost),0) FROM dbo.YS_MATERIAL_HISTORY_INFO WHERE task_code='" + task_code + "' AND material_code LIKE '01.03%'),( SELECT ISNULL(SUM(c_total_cost),0) FROM dbo.YS_MATERIAL_HISTORY_INFO WHERE task_code='" + task_code + "' AND (material_code LIKE '01.08%' OR material_code LIKE '01.09%')),( SELECT ISNULL(SUM(c_total_cost),0) FROM dbo.YS_MATERIAL_HISTORY_INFO WHERE task_code='" + task_code + "' AND material_code NOT LIKE '01.07%' AND material_code NOT LIKE '01.11%' AND material_code NOT LIKE '01.15%' AND material_code NOT LIKE '01.03%' AND material_code NOT LIKE '01.08%' AND material_code NOT LIKE '01.09%'), GETDATE(), 1,( SELECT TSA_CONTYPE FROM TBPM_TCTSASSGN WHERE TSA_ID='" + task_code + "' ) FROM dbo.View_TM_TaskAssign WHERE TSA_ID = '" + task_code + "'"; DataTable dt = DBCallCommon.GetDTUsingSqlText(sqlText); ////任务预算编制更新的时间和人员以及更新的各种材料价格 listsql.Add(string.Format("UPDATE dbo.YS_TASK_BUDGET SET task_weight= '{0}',ys_ferrous_metal_dep='{1}',ys_ferrous_metal='{1}', ys_purchase_part_dep='{2}',ys_purchase_part='{2}', ys_paint_coating_dep='{3}',ys_paint_coating='{3}',ys_electrical_dep='{4}', ys_electrical='{4}', ys_casting_forging_dep='{5}',ys_casting_forging_cost='{5}',ys_othermat_cost_dep='{6}',ys_othermat_cost='{6}',change_time=GETDATE(),change_name='" + Session["UserName"] + "' WHERE task_code='{7}';", dt.Rows[0][4].ToString(), dt.Rows[0][5].ToString(), dt.Rows[0][6].ToString(), dt.Rows[0][7].ToString(), dt.Rows[0][8].ToString(), dt.Rows[0][9].ToString(), dt.Rows[0][10].ToString(), task_code)); DBCallCommon.ExecuteTrans(listsql); listsql.Clear(); tb = new YS_Data.Model.TaskBudget(task_code); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('提交成功!');window.location='ys_task_budget_change.aspx'", true); } }
protected void Page_Load(object sender, EventArgs e) { task_code = Request.QueryString["tsak_code"] + ""; tb = new YS_Data.Model.TaskBudget(task_code); if (!IsPostBack) { userid = Session["UserID"] + ""; initControlUseable(); bindControlValue(); bindRepeater(); } }
//如何获取主键 private void InsusButton_Click(object sender, EventArgs e) { Button button = (Button)sender; //判断HiddenField是否存在 if (button.NamingContainer.FindControl("HiddenField1") != null) { //存在,把对象转换为HiddenField控件 HiddenField hf = (HiddenField)button.NamingContainer.FindControl("HiddenField1"); //取出HiddenField的Value值。 //得到更新的预算任务号 string task_code = hf.Value; tb = new YS_Data.Model.TaskBudget(task_code); } }
/// <summary> /// 完成当前节点并驳回到指定节点 /// </summary> /// <param name="node_definition_id">当前节点的node类id</param> /// <param name="tb">任务预算对象</param> public void rejectNode(string node_definition_id, YS_Data.Model.TaskBudget tb, string inids) { switch (node_definition_id) { case "6": //生产部驳回 DBCallCommon.ExeSqlText(string.Format("UPDATE {0} SET production_check={1} WHERE task_code='{2}';", TABLE_TASK_BUDGET, tb.production_check, tb.task_code)); BudgetFlowEngine.backToPreNode(tb.task_code, tb.node_production_check_note, node_definition_id, inids); break; case "14": //采购部驳回 DBCallCommon.ExeSqlText(string.Format("UPDATE {0} SET purchase_check={1} WHERE task_code='{2}';", TABLE_TASK_BUDGET, tb.purchase_check, tb.task_code)); BudgetFlowEngine.backToPreNode(tb.task_code, tb.node_purchase_check_note, node_definition_id, inids); break; case "16": //财务部驳回 DBCallCommon.ExeSqlText(string.Format("UPDATE {0} SET state=3,budget_check={1} WHERE task_code='{2}';", TABLE_TASK_BUDGET, tb.budget_check, tb.task_code)); BudgetFlowEngine.backToPreNode(tb.task_code, tb.node_budget_check_note, node_definition_id, inids); break; default: break; } }
/// <summary> /// 完成当前节点并激活下一节点 /// </summary> /// <param name="node_definition_id">当前节点的node类id</param> /// <param name="tb">任务预算对象</param> public void finishNode(string node_definition_id, YS_Data.Model.TaskBudget tb) { switch (node_definition_id) { case "1": //财务初步编制 DBCallCommon.ExeSqlText(string.Format("UPDATE {0} SET direct_labour_budget_pre={1},sub_teamwork_budget_pre={2},cooperative_product_budget_pre={3},total_material_budget_pre={4}, state=2 WHERE task_code='{5}';", TABLE_TASK_BUDGET, tb.labour_budget_pre, tb.teamwork_budget_pre, tb.cooperative_budget_pre, tb.total_material_budget_pre, tb.task_code)); if (BudgetFlowEngine.completeCurrentNode(tb.task_code, node_definition_id, "NULL")) { string[] ids1 = new string[] { BudgetFlowEngine.getFirstCellStringByDR(string.Format("SELECT ST_ID FROM TBDS_STAFFINFO WHERE ST_POSITION={0} AND ST_PD=0;", ConfigurationSettings.AppSettings["BudgetProductionCheck"])), BudgetFlowEngine.getFirstCellStringByDR(string.Format("SELECT ST_ID FROM TBDS_STAFFINFO WHERE ST_POSITION={0} AND ST_PD=0;", ConfigurationSettings.AppSettings["BudgetPurchaseCheck"])) }; //获得生产部分工人、采购分工人id BudgetFlowEngine.activeFollowNode(tb.task_code, node_definition_id, ids1); } break; case "2": //生产部长分工 if (BudgetFlowEngine.completeCurrentNode(tb.task_code, node_definition_id, "NULL")) { string[] ids2 = new string[] { tb.node_labour_dep_user_id, tb.node_teamwork_dep_user_id, tb.node_cooperative_dep_user_id }; BudgetFlowEngine.activeFollowNode(tb.task_code, node_definition_id, ids2); } break; case "3": //人工费反馈 DBCallCommon.ExeSqlText(string.Format("UPDATE {0} SET direct_labour_dep={1} WHERE task_code='{2}';", TABLE_TASK_BUDGET, tb.labour_dep, tb.task_code)); if (BudgetFlowEngine.completeCurrentNode(tb.task_code, node_definition_id, tb.node_labour_dep_note)) { DBCallCommon.ExeSqlText(string.Format("UPDATE {0} SET production_check=2 WHERE task_code='{1}';", TABLE_TASK_BUDGET, tb.task_code)); string[] ids3 = new string[] { BudgetFlowEngine.getFirstCellStringByDR(string.Format("SELECT ST_ID FROM TBDS_STAFFINFO WHERE ST_POSITION={0} AND ST_PD=0;", ConfigurationSettings.AppSettings["BudgetProductionCheck"])) }; BudgetFlowEngine.activeFollowNode(tb.task_code, node_definition_id, ids3); } break; case "4": //分包费反馈 DBCallCommon.ExeSqlText(string.Format("UPDATE {0} SET sub_teamwork_dep={1} WHERE task_code='{2}';", TABLE_TASK_BUDGET, tb.teamwork_dep, tb.task_code)); if (BudgetFlowEngine.completeCurrentNode(tb.task_code, node_definition_id, tb.node_teamwork_dep_note)) { DBCallCommon.ExeSqlText(string.Format("UPDATE {0} SET production_check=2 WHERE task_code='{1}';", TABLE_TASK_BUDGET, tb.task_code)); string[] ids4 = new string[] { BudgetFlowEngine.getFirstCellStringByDR(string.Format("SELECT ST_ID FROM TBDS_STAFFINFO WHERE ST_POSITION={0} AND ST_PD=0;", ConfigurationSettings.AppSettings["BudgetProductionCheck"])) }; BudgetFlowEngine.activeFollowNode(tb.task_code, node_definition_id, ids4); } break; case "5": //外协费反馈 DBCallCommon.ExeSqlText(string.Format("UPDATE {0} SET cooperative_product_dep={1} WHERE task_code='{2}';", TABLE_TASK_BUDGET, tb.cooperative_dep, tb.task_code)); if (BudgetFlowEngine.completeCurrentNode(tb.task_code, node_definition_id, tb.node_cooperative_dep_note)) { DBCallCommon.ExeSqlText(string.Format("UPDATE {0} SET production_check=2 WHERE task_code='{1}';", TABLE_TASK_BUDGET, tb.task_code)); string[] ids5 = new string[] { BudgetFlowEngine.getFirstCellStringByDR(string.Format("SELECT ST_ID FROM TBDS_STAFFINFO WHERE ST_POSITION={0} AND ST_PD=0;", ConfigurationSettings.AppSettings["BudgetProductionCheck"])) }; BudgetFlowEngine.activeFollowNode(tb.task_code, node_definition_id, ids5); } break; case "6": //生产部长审核 DBCallCommon.ExeSqlText(string.Format("UPDATE {0} SET production_check={1} WHERE task_code='{2}';", TABLE_TASK_BUDGET, tb.production_check, tb.task_code)); if (BudgetFlowEngine.completeCurrentNode(tb.task_code, node_definition_id, tb.node_production_check_note)) { DBCallCommon.ExeSqlText(string.Format("UPDATE {0} SET state=3 WHERE task_code='{1}';", TABLE_TASK_BUDGET, tb.task_code)); string[] ids6 = new string[] { ConfigurationSettings.AppSettings["BudgetEditorId"] + "" }; BudgetFlowEngine.activeFollowNode(tb.task_code, node_definition_id, ids6); } break; case "7": //采购部长分工 if (BudgetFlowEngine.completeCurrentNode(tb.task_code, node_definition_id, "NULL")) { string[] ids7 = new string[] { tb.node_ferrous_dep_user_id, tb.node_purchasepart_dep_user_id, tb.node_paint_dep_user_id, tb.node_electrical_dep_user_id, tb.node_casting_dep_user_id, tb.node_othermat_dep_user_id }; BudgetFlowEngine.activeFollowNode(tb.task_code, node_definition_id, ids7); } break; case "8": //黑色金属反馈 DBCallCommon.ExeSqlText(string.Format("UPDATE {0} SET ys_ferrous_metal_dep={1} WHERE task_code='{2}';", TABLE_TASK_BUDGET, tb.ferrous_dep, tb.task_code)); if (BudgetFlowEngine.completeCurrentNode(tb.task_code, node_definition_id, tb.node_ferrous_dep_note)) { DBCallCommon.ExeSqlText(string.Format("UPDATE {0} SET purchase_check=2 WHERE task_code='{1}';", TABLE_TASK_BUDGET, tb.task_code)); string[] ids8 = new string[] { BudgetFlowEngine.getFirstCellStringByDR(string.Format("SELECT ST_ID FROM TBDS_STAFFINFO WHERE ST_POSITION={0} AND ST_PD=0;", ConfigurationSettings.AppSettings["BudgetPurchaseCheck"])) }; BudgetFlowEngine.activeFollowNode(tb.task_code, node_definition_id, ids8); } break; case "9": //外购件反馈 DBCallCommon.ExeSqlText(string.Format("UPDATE {0} SET ys_purchase_part_dep={1} WHERE task_code='{2}';", TABLE_TASK_BUDGET, tb.purchasepart_dep, tb.task_code)); if (BudgetFlowEngine.completeCurrentNode(tb.task_code, node_definition_id, tb.node_purchasepart_dep_note)) { DBCallCommon.ExeSqlText(string.Format("UPDATE {0} SET purchase_check=2 WHERE task_code='{1}';", TABLE_TASK_BUDGET, tb.task_code)); string[] ids9 = new string[] { BudgetFlowEngine.getFirstCellStringByDR(string.Format("SELECT ST_ID FROM TBDS_STAFFINFO WHERE ST_POSITION={0} AND ST_PD=0;", ConfigurationSettings.AppSettings["BudgetPurchaseCheck"])) }; BudgetFlowEngine.activeFollowNode(tb.task_code, node_definition_id, ids9); } break; case "10": //油漆涂料反馈 DBCallCommon.ExeSqlText(string.Format("UPDATE {0} SET ys_paint_coating_dep={1} WHERE task_code='{2}';", TABLE_TASK_BUDGET, tb.paint_dep, tb.task_code)); if (BudgetFlowEngine.completeCurrentNode(tb.task_code, node_definition_id, tb.node_paint_dep_note)) { DBCallCommon.ExeSqlText(string.Format("UPDATE {0} SET purchase_check=2 WHERE task_code='{1}';", TABLE_TASK_BUDGET, tb.task_code)); string[] ids10 = new string[] { BudgetFlowEngine.getFirstCellStringByDR(string.Format("SELECT ST_ID FROM TBDS_STAFFINFO WHERE ST_POSITION={0} AND ST_PD=0;", ConfigurationSettings.AppSettings["BudgetPurchaseCheck"])) }; BudgetFlowEngine.activeFollowNode(tb.task_code, node_definition_id, ids10); } break; case "11": //电器电料反馈 DBCallCommon.ExeSqlText(string.Format("UPDATE {0} SET ys_electrical_dep={1} WHERE task_code='{2}';", TABLE_TASK_BUDGET, tb.electrical_dep, tb.task_code)); if (BudgetFlowEngine.completeCurrentNode(tb.task_code, node_definition_id, tb.node_electrical_dep_note)) { DBCallCommon.ExeSqlText(string.Format("UPDATE {0} SET purchase_check=2 WHERE task_code='{1}';", TABLE_TASK_BUDGET, tb.task_code)); string[] ids11 = new string[] { BudgetFlowEngine.getFirstCellStringByDR(string.Format("SELECT ST_ID FROM TBDS_STAFFINFO WHERE ST_POSITION={0} AND ST_PD=0;", ConfigurationSettings.AppSettings["BudgetPurchaseCheck"])) }; BudgetFlowEngine.activeFollowNode(tb.task_code, node_definition_id, ids11); } break; case "12": //铸锻件反馈 DBCallCommon.ExeSqlText(string.Format("UPDATE {0} SET ys_casting_forging_dep={1} WHERE task_code='{2}';", TABLE_TASK_BUDGET, tb.casting_dep, tb.task_code)); if (BudgetFlowEngine.completeCurrentNode(tb.task_code, node_definition_id, tb.node_casting_dep_note)) { DBCallCommon.ExeSqlText(string.Format("UPDATE {0} SET purchase_check=2 WHERE task_code='{1}';", TABLE_TASK_BUDGET, tb.task_code)); string[] ids12 = new string[] { BudgetFlowEngine.getFirstCellStringByDR(string.Format("SELECT ST_ID FROM TBDS_STAFFINFO WHERE ST_POSITION={0} AND ST_PD=0;", ConfigurationSettings.AppSettings["BudgetPurchaseCheck"])) }; BudgetFlowEngine.activeFollowNode(tb.task_code, node_definition_id, ids12); } break; case "13": //其他材料反馈 DBCallCommon.ExeSqlText(string.Format("UPDATE {0} SET ys_othermat_cost_dep={1} WHERE task_code='{2}';", TABLE_TASK_BUDGET, tb.othermat_dep, tb.task_code)); if (BudgetFlowEngine.completeCurrentNode(tb.task_code, node_definition_id, tb.node_othermat_dep_note)) { DBCallCommon.ExeSqlText(string.Format("UPDATE {0} SET purchase_check=2 WHERE task_code='{1}';", TABLE_TASK_BUDGET, tb.task_code)); string[] ids13 = new string[] { BudgetFlowEngine.getFirstCellStringByDR(string.Format("SELECT ST_ID FROM TBDS_STAFFINFO WHERE ST_POSITION={0} AND ST_PD=0;", ConfigurationSettings.AppSettings["BudgetPurchaseCheck"])) }; BudgetFlowEngine.activeFollowNode(tb.task_code, node_definition_id, ids13); } break; case "14": //采购部长审核 DBCallCommon.ExeSqlText(string.Format("UPDATE {0} SET purchase_check={1} WHERE task_code='{2}';", TABLE_TASK_BUDGET, tb.purchase_check, tb.task_code)); if (BudgetFlowEngine.completeCurrentNode(tb.task_code, node_definition_id, tb.node_purchase_check_note)) { DBCallCommon.ExeSqlText(string.Format("UPDATE {0} SET state=3 WHERE task_code='{1}';", TABLE_TASK_BUDGET, tb.task_code)); string[] ids14 = new string[] { ConfigurationSettings.AppSettings["BudgetEditorId"] + "" }; BudgetFlowEngine.activeFollowNode(tb.task_code, node_definition_id, ids14); } break; case "15": //预算调整 DBCallCommon.ExeSqlText(string.Format("UPDATE {0} SET direct_labour_budget={1},sub_teamwork_budget={2},cooperative_product_budget={3},total_material_budget={4}, state=4 WHERE task_code='{5}';", TABLE_TASK_BUDGET, tb.labour_budget, tb.teamwork_budget, tb.cooperative_budget, tb.total_material_budget, tb.task_code)); if (BudgetFlowEngine.completeCurrentNode(tb.task_code, node_definition_id, "NULL")) { DBCallCommon.ExeSqlText(string.Format("UPDATE {0} SET budget_check=2 WHERE task_code='{1}';", TABLE_TASK_BUDGET, tb.task_code)); string[] ids15 = new string[] { BudgetFlowEngine.getFirstCellStringByDR(string.Format("SELECT ST_ID FROM TBDS_STAFFINFO WHERE ST_POSITION={0} AND ST_PD=0;", ConfigurationSettings.AppSettings["BudgetFinanceCheck"])) }; //获得财务部审核人id BudgetFlowEngine.activeFollowNode(tb.task_code, node_definition_id, ids15); } break; case "16": //财务部长审核 DBCallCommon.ExeSqlText(string.Format("UPDATE {0} SET budget_check={1}, state=5,end_time=GETDATE() WHERE task_code='{2}';", TABLE_TASK_BUDGET, tb.budget_check, tb.task_code)); if (BudgetFlowEngine.completeCurrentNode(tb.task_code, node_definition_id, tb.node_budget_check_note)) { string[] ids16 = new string[] { "0" }; BudgetFlowEngine.activeFollowNode(tb.task_code, node_definition_id, ids16); } break; default: break; } }