public static int UpdateStep(Model.mg_StepModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update mg_step set "); strSql.Append("step_name=@step_name,"); //strSql.Append("fl_id=@fl_id,"); strSql.Append("st_id=@st_id,"); strSql.Append("bom_id=@bom_id,"); strSql.Append("part_id=@part_id,"); strSql.Append("bom_count=@bom_count,"); strSql.Append("step_clock=@step_clock,"); strSql.Append("step_desc=@step_desc,"); strSql.Append("step_pic=@step_pic,"); strSql.Append("barcode_start=@barcode_start,"); strSql.Append("barcode_number=@barcode_number,"); strSql.Append("step_plccode=@step_plccode"); strSql.Append(" where step_id=@step_id "); SqlParameter[] parameters = { new SqlParameter("@step_id", SqlDbType.Int), new SqlParameter("@step_name", SqlDbType.NVarChar), //new SqlParameter("@fl_id", SqlDbType.Int), new SqlParameter("@st_id", SqlDbType.Int), new SqlParameter("@bom_id", SqlDbType.Int), new SqlParameter("@bom_count", SqlDbType.Int), new SqlParameter("@step_clock", SqlDbType.Int), new SqlParameter("@step_desc", SqlDbType.NVarChar), new SqlParameter("@step_pic", SqlDbType.NVarChar), new SqlParameter("@step_plccode", SqlDbType.Int), new SqlParameter("@barcode_start", SqlDbType.Int), new SqlParameter("@barcode_number", SqlDbType.Int), new SqlParameter("@part_id", SqlDbType.Int) }; parameters[0].Value = model.step_id; parameters[1].Value = model.step_name; //parameters[2].Value = model.fl_id; parameters[2].Value = model.st_id; parameters[3].Value = model.bom_id; parameters[4].Value = model.bom_count; parameters[5].Value = model.step_clock; parameters[6].Value = model.step_desc; parameters[7].Value = model.step_pic; parameters[8].Value = model.step_plccode; parameters[9].Value = model.barcode_start; parameters[10].Value = model.barcode_number; parameters[11].Value = model.part_id; int rows = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, System.Data.CommandType.Text, strSql.ToString(), parameters); return(rows); }
public static int UpdateStepAndODS(Model.mg_StepModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update mg_step set "); strSql.Append("step_name=@step_name,"); // strSql.Append("fl_id=@fl_id,"); strSql.Append("st_id=@st_id,"); strSql.Append("bom_id=@bom_id,"); strSql.Append("part_id=@part_id,"); strSql.Append("bom_count=@bom_count,"); strSql.Append("step_clock=@step_clock,"); strSql.Append("step_desc=@step_desc,"); strSql.Append("step_pic=@step_pic,"); strSql.Append("step_plccode=@step_plccode"); strSql.Append(" where step_id=@step_id ;"); SqlParameter[] parameters = { new SqlParameter("@step_id", SqlDbType.Int), new SqlParameter("@step_name", SqlDbType.NVarChar), //new SqlParameter("@fl_id", SqlDbType.Int), new SqlParameter("@st_id", SqlDbType.Int), new SqlParameter("@bom_id", SqlDbType.Int), new SqlParameter("@bom_count", SqlDbType.Int), new SqlParameter("@step_clock", SqlDbType.Int), new SqlParameter("@step_desc", SqlDbType.NVarChar), new SqlParameter("@step_pic", SqlDbType.NVarChar), new SqlParameter("@step_plccode", SqlDbType.Int), new SqlParameter("@part_id", SqlDbType.Int) }; parameters[0].Value = model.step_id; parameters[1].Value = model.step_name; // parameters[2].Value = model.fl_id; parameters[2].Value = model.st_id; parameters[3].Value = model.bom_id; parameters[4].Value = model.bom_count; parameters[5].Value = model.step_clock; parameters[6].Value = model.step_desc; parameters[7].Value = model.step_pic; parameters[8].Value = model.step_plccode; parameters[9].Value = model.part_id; if (!string.IsNullOrEmpty(model.odsName)) { strSql.Append(" delete from mg_ODS where step_id=" + model.step_id + ";"); string[] odsnameArr = model.odsName.Split('|'); string[] odskeyArr = model.odsKeyword.Split('|'); string odsStr = @"INSERT INTO [mg_ODS] ([ods_id] ,[step_id] ,[ods_name] ,[ods_keywords]) VALUES ($ods_id$ ,$step_id$ ,'$ods_name$' ,'$ods_keywords$');"; for (int i = 0; i < odsnameArr.Length; i++) { string key = ""; if ((i + 1) <= odskeyArr.Length) { key = odskeyArr[i]; } strSql.Append(odsStr.Replace("$ods_id$", (i + 1).ToString()).Replace("$step_id$", model.step_id.ToString()).Replace("$ods_name$", odsnameArr[i]).Replace("$ods_keywords$", key)); } } int rows = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, System.Data.CommandType.Text, strSql.ToString(), parameters); return(rows); }