/// <summary> /// 执行存储过程验证序号(保存时) /// </summary> /// <param name="psv"></param> private void ExecSpareParts(ParamsBj pbj) { try { SqlConnection sqlConn = new SqlConnection(); SqlCommand sqlCmd = new SqlCommand(); sqlConn.ConnectionString = DBCallCommon.GetStringValue("connectionStrings"); DBCallCommon.PrepareStoredProc(sqlConn, sqlCmd, "[PRO_TM_SparePartsGen]"); DBCallCommon.AddParameterToStoredProc(sqlCmd, "@TableName", pbj.TableName, SqlDbType.Text, 1000); DBCallCommon.AddParameterToStoredProc(sqlCmd, "@EngID", pbj.EngID, SqlDbType.Text, 1000); DBCallCommon.AddParameterToStoredProc(sqlCmd, "@BjType", pbj.BjType, SqlDbType.Text, 1000); DBCallCommon.AddParameterToStoredProc(sqlCmd, "@CalType", pbj.CalType, SqlDbType.Text, 1000); DBCallCommon.AddParameterToStoredProc(sqlCmd, "@BjFather", pbj.BjFather, SqlDbType.Text, 1000); DBCallCommon.AddParameterToStoredProc(sqlCmd, "@UserID", pbj.UserID, SqlDbType.Text, 1000); DBCallCommon.AddParameterToStoredProc(sqlCmd, "@Xishu", pbj.Xishu, SqlDbType.Text, 1000); DBCallCommon.AddParameterToStoredProc(sqlCmd, "@WaitFor", pbj.WaitFor, SqlDbType.Text, 3000); DBCallCommon.AddParameterToStoredProc(sqlCmd, "@BiaoShi", pbj.BiaoShi, SqlDbType.Text, 3000); sqlConn.Open(); sqlCmd.ExecuteNonQuery(); sqlConn.Close(); } catch (Exception) { throw; } }
/// <summary> /// 生成备件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnCreate_OnClick(object sender, EventArgs e) { if (txtBiaoshi.Text.Trim() == "如:FER-SRC135.02.04.04" || txtBiaoshi.Text.Trim() == "") { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('请输入【标识前缀】!!!');", true); return; } if (ddlBJFA.SelectedIndex == 0) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('请选择【生成备件父级】!!!\\r\\r提示:如果没有记录,请在BOM录入界面输入【随机备件】');", true); } else { ParamsBj param = new ParamsBj(); param.BjFather = ddlBJFA.SelectedValue; param.BjType = ddlBJType.SelectedValue; param.CalType = ddlJiSuanType.SelectedValue; param.EngID = ViewState["TaskID"].ToString(); param.TableName = ViewState["tablename"].ToString(); param.UserID = Session["UserID"].ToString(); param.Xishu = txtXiShu.Text.Trim(); param.BiaoShi = txtBiaoshi.Text.Trim(); string waitfor = ""; foreach (GridViewRow grow in GridView1.Rows) { if (((CheckBox)grow.FindControl("CheckBox2")).Checked) { waitfor += ((Label)grow.FindControl("Label1")).Text.Trim() + ','; } } param.WaitFor = waitfor.Substring(0, waitfor.Length - 1); if (param.WaitFor.Length > 3000) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('对不起,您选择的记录过多,请减少勾选记录后再试!!!');", true); return; } try { this.ExecSpareParts(param); this.btnQurey_OnClick(null, null); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('备件已生成成功!!!\\r\\r提示:如需修改请进入查看界面!!!');", true); } catch { string error_detail = "程序出现未知错误,请联系管理员!!!"; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('" + error_detail + "');", true); } } }