/// <summary> /// 保存模板信息 /// </summary> /// <returns></returns> public string Save_Modle(DataTable dt) { try { string result = "1"; TransactionHelper.BeginTransaction(); string strUserID = RV.UI.UserInfo.userID; DateTime time = RV.UI.ServerTime.timeNow(); Dal_TQB_SAMP_ITEM_MODLE dalTqbItem = new Dal_TQB_SAMP_ITEM_MODLE(); Dal_TQB_SAMPLING dalTqbSampling = new Dal_TQB_SAMPLING(); dalTqbItem.Update_Trans(dt.Rows[0]["执行标准"].ToString(), dt.Rows[0]["钢种"].ToString(), dt.Rows[0]["规格最小值"].ToString(), dt.Rows[0]["规格最大值"].ToString()); if (!dal.update_Trans(dt.Rows[0]["执行标准"].ToString(), dt.Rows[0]["钢种"].ToString(), dt.Rows[0]["规格最小值"].ToString(), dt.Rows[0]["规格最大值"].ToString())) { TransactionHelper.RollBack(); return("保存失败!"); } for (int irow = 0; irow < dt.Rows.Count; irow++) { Int64 i_ID = dal.Get_Max_ID_Trans(); i_ID++; Mod_TQB_SAMP_MODLE modMain = new Mod_TQB_SAMP_MODLE(); modMain.C_ID = i_ID.ToString(); modMain.C_STD_CODE = dt.Rows[irow]["执行标准"].ToString(); modMain.C_STL_GRD = dt.Rows[irow]["钢种"].ToString(); modMain.C_SPEC_MIN = dt.Rows[irow]["规格最小值"].ToString(); modMain.C_SPEC_MAX = dt.Rows[irow]["规格最大值"].ToString(); modMain.N_SAM_NUM = Convert.ToDecimal(dt.Rows[irow]["取样数量"].ToString()); modMain.C_EMP_ID = strUserID; modMain.D_MOD_DT = time; if (!dal.Add_Trans(modMain)) { TransactionHelper.RollBack(); return("保存失败!"); } for (int icol = 6; icol < dt.Columns.Count; icol++) { if (!string.IsNullOrEmpty(dt.Rows[irow][icol].ToString().Trim())) { Mod_TQB_SAMP_ITEM_MODLE modItem = new Mod_TQB_SAMP_ITEM_MODLE(); string SampId = dalTqbSampling.GetSampId(dt.Columns[icol].ColumnName, "质控部"); modItem.C_SAMP_MODLE_ID = i_ID.ToString(); modItem.C_SAMPLES_ID = SampId; modItem.C_SAM_NUM = dt.Rows[irow][icol].ToString(); modItem.C_EMP_ID = strUserID; modItem.D_MOD_DT = time; modItem.C_SAMPLES_NAME = dt.Columns[icol].ColumnName; if (!dalTqbItem.Add_Trans(modItem)) { TransactionHelper.RollBack(); return("保存失败!"); } } } } TransactionHelper.Commit(); return(result); } catch (Exception ex) { TransactionHelper.RollBack(); return(ex.Message); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update_Trans(string C_SAMP_MODLE_ID) { return(dal.Update_Trans(C_SAMP_MODLE_ID)); }