private string ExecMsCreate(MSCreate mscreate) { DataTable dt; try { SqlConnection sqlConn = new SqlConnection(); SqlCommand sqlCmd = new SqlCommand(); sqlConn.ConnectionString = DBCallCommon.GetStringValue("connectionStrings"); DBCallCommon.PrepareStoredProc(sqlConn, sqlCmd, "[PRO_TM_MS_NorCreate]"); DBCallCommon.AddParameterToStoredProc(sqlCmd, "@StrTabeleName", mscreate.StrTabeleName, SqlDbType.Text, 1000); DBCallCommon.AddParameterToStoredProc(sqlCmd, "@ViewTabelName", mscreate.ViewTabelName, SqlDbType.Text, 1000); DBCallCommon.AddParameterToStoredProc(sqlCmd, "@TaskID", mscreate.TaskID, SqlDbType.Text, 1000); DBCallCommon.AddParameterToStoredProc(sqlCmd, "@MS_PID", mscreate.MS_PID, SqlDbType.Text, 1000); DBCallCommon.AddParameterToStoredProc(sqlCmd, "@MsTableName", mscreate.MsTableName, SqlDbType.Text, 1000); DBCallCommon.AddParameterToStoredProc(sqlCmd, "@MsRewTabelName", mscreate.MsRewTabelName, SqlDbType.Text, 1000); DBCallCommon.AddParameterToStoredProc(sqlCmd, "@SubmitID", mscreate.SubmitID, SqlDbType.Text, 1000); sqlConn.Open(); dt = DBCallCommon.GetDataTableUsingCmd(sqlCmd); sqlConn.Close(); } catch (Exception) { return("1"); } return(dt.Rows[0][0].ToString()); }
/// <summary> /// 生成制作明细 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnMSCreate_OnClick(object sender, EventArgs e) { if (Session["MSNorSubmited"].ToString() == "已提交") { btnMSCreate.Visible = false; // btnBack.Visible = false; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('请勿重复提交!!!\\r\\r提示:数据已提交,即将关闭当前窗口!!!');window.close();", true); } else { if (ddlShebei.SelectedIndex == 0) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('请选择设备,图号!');", true); return; } List <string> list_insert_ms = new List <string>(); //获取变更批号(从正常审核表中找出,变更批号次数) string sql_get_pici = "select count(*) from TBPM_MSCHANGERVW where MS_ENGID='" + tsaid.Text + "' and cast(MS_STATE as int)>1 and MS_ID like '%JSB MSBG%'"; DataTable dt_pici = DBCallCommon.GetDTUsingSqlText(sql_get_pici); string pici = (Convert.ToInt16(dt_pici.Rows[0][0].ToString()) + 1).ToString();//当前批次 string ms_no = tsaid.Text + "." + "JSB MSBG" + "/" + pici.PadLeft(2, '0'); //更改原始数据中的明细过渡状态 string sql_update_org_mstemp = "update TBPM_STRINFODQO set BM_MSTEMP='1' where BM_ENGID='" + tsaid.Text + "' and BM_MSSTATUS!='0' and BM_XUHAO<>'1.0' and BM_XUHAO not like '%.0.%' AND BM_MSSTATE='0' and BM_MSSTATUS<>'0'"; sql_update_org_mstemp += this.strWhereXuhao(); DBCallCommon.ExeSqlText(sql_update_org_mstemp); //借助存储过程生成制作明细 MSCreate classMSCreate = new MSCreate(); classMSCreate.MS_PID = ms_no; classMSCreate.StrTabeleName = "TBPM_STRINFODQO"; classMSCreate.ViewTabelName = "View_TM_DQO"; classMSCreate.TaskID = tsaid.Text; classMSCreate.MsTableName = "TBPM_MKDETAIL"; classMSCreate.MsRewTabelName = "TBPM_MSCHANGERVW"; classMSCreate.SubmitID = Session["UserID"].ToString(); string ret = this.ExecMsCreate(classMSCreate); if (ret == "0") { Session["MSNorSubmited"] = "已提交"; string sql_select_reviewa = "select TSA_REVIEWERID from TBPM_TCTSASSGN where TSA_ID='" + tsaid.Text + "'"; DataTable dt_review = DBCallCommon.GetDTUsingSqlText(sql_select_reviewa); if (dt_review.Rows.Count > 0) { string sql_set_reviewa = "update TBPM_MSCHANGERVW set MS_REVIEWA='" + dt_review.Rows[0][0].ToString() + "',MS_MAP='" + ddlShebei.SelectedValue.Split('|')[0] + "',MS_CHILDENGNAME='" + ddlShebei.SelectedValue.Split('|')[1] + "' where MS_ID='" + ms_no + "'"; DBCallCommon.ExeSqlText(sql_set_reviewa); } Response.Redirect("TM_MS_Detail_Audit.aspx?id=" + ms_no); } else { sql_update_org_mstemp = "update TBPM_STRINFODQO set BM_MSTEMP='0' where BM_ENGID='" + tsaid.Text + "' and BM_MSSTATUS!='0'"; sql_update_org_mstemp += this.strWhereXuhao(); DBCallCommon.ExeSqlText(sql_update_org_mstemp); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('程序异常,请稍后再试!!!');window.close();", true); } } }
/// <summary> /// 生成制作明细 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnMSCreate_OnClick(object sender, EventArgs e) { if (Session["MSNorSubmited"].ToString() == "已提交") { btnMSCreate.Visible = false; btnBack.Visible = false; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('请勿重复提交!!!\\r\\r提示:数据已提交,即将关闭当前窗口!!!');window.close();", true); } else { if (ddlShebei.SelectedIndex == 0) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('请选择设备,图号!')", true); } else { List <string> list_insert_ms = new List <string>(); //获取正常批号 string sql_get_pici = "select count(*) from TBPM_MSFORALLRVW where MS_ENGID='" + tsaid.Text + "' and cast(MS_STATE as int)>1"; DataTable dt_pici = DBCallCommon.GetDTUsingSqlText(sql_get_pici); string pici = (Convert.ToInt16(dt_pici.Rows[0][0].ToString()) + 1).ToString();//当前批次 string ms_no = tsaid.Text + "." + "MS" + "/" + pici.PadLeft(2, '0'); //更改原始数据中的明细过渡状态 string sql_update_org_mstemp = "update " + strtable + " set BM_MSTEMP='1' where BM_ENGID='" + tsaid.Text + "' and " + ViewState["xuhao_str"] + " and BM_ISMANU='Y' and BM_MSSTATE='0' and BM_MSSTATUS='0'"; DBCallCommon.ExeSqlText(sql_update_org_mstemp); //借助存储过程生成正常制作明细 MSCreate classMSCreate = new MSCreate(); classMSCreate.MS_PID = ms_no; classMSCreate.StrTabeleName = strtable; classMSCreate.ViewTabelName = "View_TM_DQO"; classMSCreate.TaskID = ViewState["TaskId"].ToString(); classMSCreate.MsTableName = "TBPM_MKDETAIL"; classMSCreate.MsRewTabelName = "TBPM_MSFORALLRVW"; classMSCreate.SubmitID = Session["UserID"].ToString(); string ret = this.ExecMsCreate(classMSCreate); if (ret == "0") { Session["MSNorSubmited"] = "已提交"; string sql_select_reviewa = "select TSA_REVIEWERID from TBPM_TCTSASSGN where TSA_ID='" + ViewState["TaskId"].ToString() + "'"; DataTable dt_review = DBCallCommon.GetDTUsingSqlText(sql_select_reviewa); if (dt_review.Rows.Count > 0) { string sql_set_reviewa = "update TBPM_MSFORALLRVW set MS_REVIEWA='" + dt_review.Rows[0][0].ToString() + "',MS_MAP='" + ddlShebei.SelectedValue.Split('|')[0] + "',MS_CHILDENGNAME='" + ddlShebei.SelectedValue.Split('|')[1] + "' where MS_ID='" + ms_no + "'"; DBCallCommon.ExeSqlText(sql_set_reviewa); } Response.Redirect("TM_MS_Detail_Audit.aspx?id=" + ms_no); //ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "window.location.replace('TM_Md_Detail_List.aspx?id='+" + ms_no+");", true); } else { sql_update_org_mstemp = "update " + strtable + " set BM_MSTEMP='0' where BM_ENGID='" + tsaid.Text + "' and " + ViewState["xuhao_str"] + ""; DBCallCommon.ExeSqlText(sql_update_org_mstemp); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('程序异常,请稍后再试!!!');window.close();", true); } } } }