/// <summary> /// 导入excel 检测明细 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnUp_Click(object sender, EventArgs e) { if (ddlGun.SelectedValue != "0") { if (this.File1.Value == "") { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"请选择要导入的文件。\");", true); return; } string strFileName = this.SaveFile(this.File1.PostedFile); if (strFileName != "") { string readSheetName = strFileName.Remove(0, strFileName.LastIndexOf("\\") + 1);//只是获取文件的名称 string readSheetName2 = readSheetName.Remove(readSheetName.LastIndexOf(".")); DataSet ds = HS.Function.CommFunction.ReadExcel(strFileName, readSheetName2); if (ds == null || ds.Tables.Count == 0) { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"读取数据源文件时出错,请重试。\");", true); return; } if (ds.Tables[0].Columns.Count != 28)//导入的excel的 列数是否合格 { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"读取的Excel列数不正确。\");", true); return; } if (ds.Tables[0].Columns.Contains("Date") && ds.Tables[0].Columns.Contains("Reading") && ds.Tables[0].Columns.Contains("Invoice No#") && ds.Tables[0].Columns.Contains("Code No#") && ds.Tables[0].Columns.Contains("Size") && ds.Tables[0].Columns.Contains("Match1") && ds.Tables[0].Columns.Contains("Cr") && ds.Tables[0].Columns.Contains("Cr +/-") && ds.Tables[0].Columns.Contains("Ni") && ds.Tables[0].Columns.Contains("Ni +/-") && ds.Tables[0].Columns.Contains("Mo") && ds.Tables[0].Columns.Contains("Mo +/-") && ds.Tables[0].Columns.Contains("Cu") && ds.Tables[0].Columns.Contains("Cu +/-") && ds.Tables[0].Columns.Contains("Mn") && ds.Tables[0].Columns.Contains("Mn +/-") && ds.Tables[0].Columns.Contains("Fe") && ds.Tables[0].Columns.Contains("Fe +/-") && ds.Tables[0].Columns.Contains("Co") && ds.Tables[0].Columns.Contains("Co +/-") && ds.Tables[0].Columns.Contains("Nb") && ds.Tables[0].Columns.Contains("Nb +/-") && ds.Tables[0].Columns.Contains("Zr") && ds.Tables[0].Columns.Contains("Zr +/-") && ds.Tables[0].Columns.Contains("Ti") && ds.Tables[0].Columns.Contains("Ti +/-")) { } else { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"读取的Excel列不正确。\");", true); return; } ds.Tables[0].Columns.Add("error"); ds.Tables[0].Columns.Add("id"); ds.Tables[0].Columns.Add("gunid"); ds.Tables[0].Columns.Add("errormsg"); try { string maxdt = ds.Tables[0].Compute("max(Date)", "").ToString(); string mindt = ds.Tables[0].Compute("min(Date)", "").ToString(); DataSet dtSource = new DataSet(); BProductCheckDetailBB productCheckDetailBB = new BProductCheckDetailBB(); StringBuilder strErrorInfo = new StringBuilder(); bool isSuccess = true; dtSource = productCheckDetailBB.GetList("checkDt between '" + Convert.ToDateTime(mindt) + "' and '" + Convert.ToDateTime(maxdt) + "'"); foreach (DataRow dr in ds.Tables[0].Rows) { string ss = " checkDt='" + dr["Date"] + "' and checkGunId=" + ddlGun.SelectedValue + " and checkGunIndex=" + dr["Reading"]; DataRow[] drs = dtSource.Tables[0].Select(" checkDt='" + dr["Date"] + "' and checkGunId=" + ddlGun.SelectedValue + " and checkGunIndex=" + dr["Reading"]); int demo = 0; if (drs.Length <= 0) { // dr["id"] = "0"; dr["error"] = Convert.ToInt32(dr["error"] == DBNull.Value ? "0" : dr["error"]) + 1; dr["errormsg"] = dr["errormsg"].ToString() + ",数据不存在"; // isSuccess = false; demo = 1; } else { dr["id"] = drs[0]["id"]; } DateTime dtnow = DateTime.Now; if (!DateTime.TryParse(dr["Date"].ToString(), out dtnow)) { dr["error"] = Convert.ToInt32(dr["error"] == DBNull.Value ? "0" : dr["error"]) + 1; dr["errormsg"] = dr["errormsg"].ToString() + ",检测日期不正确"; isSuccess = false; } int gunid = 0; if (!int.TryParse(dr["Reading"].ToString(), out gunid)) { dr["error"] = Convert.ToInt32(dr["error"] == DBNull.Value ? "0" : dr["error"]) + 1; dr["errormsg"] = dr["errormsg"].ToString() + ",检测枪号不正确"; isSuccess = false; } dr["gunid"] = this.ddlGun.SelectedValue; if (demo == 0) { BProductCheckDetailData model = new BProductCheckDetailData(); model.id = Convert.ToInt32(dr["id"]); model.checkGunId = Convert.ToInt32(ddlGun.SelectedValue); model.checkGunIndex = gunid; model.checkDt = dtnow.ToString(); model.Cr = dr["Cr"].ToString(); model.CrAdd = dr["Cr +/-"].ToString(); model.Ni = dr["Ni"].ToString(); model.NiAdd = dr["Ni +/-"].ToString(); model.Mo = dr["Mo"].ToString(); model.MoAdd = dr["Mo +/-"].ToString(); model.Cu = dr["Cu"].ToString(); model.CuAdd = dr["Cu +/-"].ToString(); model.Mn = dr["Mn"].ToString(); model.MnAdd = dr["Mn +/-"].ToString(); model.Fe = dr["Fe"].ToString(); model.FeAdd = dr["Fe +/-"].ToString(); model.Co = dr["Co"].ToString(); model.CoAdd = dr["Co +/-"].ToString(); model.Nb = dr["Nb"].ToString(); model.NbAdd = dr["Nb +/-"].ToString(); model.Zr = dr["Zr"].ToString(); model.ZrAdd = dr["Zr +/-"].ToString(); model.Ti = dr["Ti"].ToString(); model.TiAdd = dr["Ti +/-"].ToString(); this.Lists.Add(model); } } if (!isSuccess) { this.Lists.Clear(); } } catch { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"导入数据出错误!\");", true); return; } //try //{ // bool isSuccessA = plateformServicesBC.ImportRecord(modelList, this.currentUser.nowDepartId, this.currentUser.empId); // if (isAllSuccess && isSuccessA) // { // this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"平台服务商导入成功!\");", true); // } // if (!isAllSuccess) // { // this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"" + strErrorInfo.ToString() + "!\");", true); // } //} //catch (Exception ex) //{ // this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"平台服务商导入出错,请重试!\");", true); //} //finally //{ // tradeOGBB.Dispose(); // productSortBB.Dispose(); // custBB.Dispose(); // plateformServicesBC.Dispose(); //} DTResult = ds.Tables[0]; DSFlash(); } } else { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"请选择扫描枪!\");", true); } }
/// <summary> /// 增加一条数据 /// </summary> /// <param name="model">model</param> public int AddRecord(BProductCheckDetailData model) { return this.productCheckDetailDB.AddRecord(model); }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model">model</param> public bool ModifyRecord(BProductCheckDetailData model) { return this.productCheckDetailDB.ModifyRecord(model); }
/// <summary> /// 增加一条数据 /// </summary> /// <param name="model">model</param> public int AddRecord(BProductCheckDetailData model) { StringBuilder strSql = new StringBuilder(); strSql.Append("set nocount on; "); strSql.Append("insert into BProductCheckDetail("); strSql.Append(@"checkDetailId,boxNo,checkResult,noPassReasonId,checkMark,checkDt,checkGunId,checkGunIndex,Match1,Cr, CrAdd,Ni,NiAdd,Mo,MoAdd,Cu,CuAdd,Mn,MnAdd,Fe, FeAdd,Co,CoAdd,Nb,NbAdd,Zr,ZrAdd,Ti,TiAdd,weight, pullReportFileId,otherData,isrtEmpId,isrtDt,updtEmpId,updtDt)"); strSql.Append(" values ("); strSql.Append(@"@checkDetailId,@boxNo,@checkResult,@noPassReasonId,@checkMark,@checkDt,@checkGunId,@checkGunIndex,@Match1,@Cr, @CrAdd,@Ni,@NiAdd,@Mo,@MoAdd,@Cu,@CuAdd,@Mn,@MnAdd,@Fe, @FeAdd,@Co,@CoAdd,@Nb,@NbAdd,@Zr,@ZrAdd,@Ti,@TiAdd,@weight, @pullReportFileId,@otherData,@isrtEmpId,@isrtDt,@updtEmpId,@updtDt)"); strSql.Append("; select @@identity; set nocount off; "); SqlParameter[] parameters = { new SqlParameter("@checkDetailId", SqlDbType.Int), new SqlParameter("@boxNo", SqlDbType.VarChar,20), new SqlParameter("@checkResult", SqlDbType.NVarChar,20), new SqlParameter("@noPassReasonId", SqlDbType.Int), new SqlParameter("@checkMark", SqlDbType.NVarChar,200), new SqlParameter("@checkDt", SqlDbType.DateTime), new SqlParameter("@checkGunId", SqlDbType.Int), new SqlParameter("@checkGunIndex", SqlDbType.Int), new SqlParameter("@Match1", SqlDbType.NVarChar,20), new SqlParameter("@Cr", SqlDbType.NVarChar,20), new SqlParameter("@CrAdd", SqlDbType.NVarChar,20), new SqlParameter("@Ni", SqlDbType.NVarChar,20), new SqlParameter("@NiAdd", SqlDbType.NVarChar,20), new SqlParameter("@Mo", SqlDbType.NVarChar,20), new SqlParameter("@MoAdd", SqlDbType.NVarChar,20), new SqlParameter("@Cu", SqlDbType.NVarChar,20), new SqlParameter("@CuAdd", SqlDbType.NVarChar,20), new SqlParameter("@Mn", SqlDbType.NVarChar,20), new SqlParameter("@MnAdd", SqlDbType.NVarChar,20), new SqlParameter("@Fe", SqlDbType.NVarChar,20), new SqlParameter("@FeAdd", SqlDbType.NVarChar,20), new SqlParameter("@Co", SqlDbType.VarChar,20), new SqlParameter("@CoAdd", SqlDbType.VarChar,20), new SqlParameter("@Nb", SqlDbType.VarChar,20), new SqlParameter("@NbAdd", SqlDbType.VarChar,20), new SqlParameter("@Zr", SqlDbType.VarChar,20), new SqlParameter("@ZrAdd", SqlDbType.VarChar,20), new SqlParameter("@Ti", SqlDbType.VarChar,20), new SqlParameter("@TiAdd", SqlDbType.VarChar,20), new SqlParameter("@weight", SqlDbType.Float), new SqlParameter("@pullReportFileId", SqlDbType.Int), new SqlParameter("@otherData", SqlDbType.NVarChar,50), new SqlParameter("@isrtEmpId", SqlDbType.Int), new SqlParameter("@isrtDt", SqlDbType.DateTime), new SqlParameter("@updtEmpId", SqlDbType.Int), new SqlParameter("@updtDt", SqlDbType.DateTime) }; parameters[0].Value = model.checkDetailId; parameters[1].Value = model.boxNo; parameters[2].Value = model.checkResult; parameters[3].Value = model.noPassReasonId; parameters[4].Value = model.checkMark; parameters[5].Value = model.checkDt == string.Empty ? null : model.checkDt; parameters[6].Value = model.checkGunId; parameters[7].Value = model.checkGunIndex; parameters[8].Value = model.Match1; parameters[9].Value = model.Cr; parameters[10].Value = model.CrAdd; parameters[11].Value = model.Ni; parameters[12].Value = model.NiAdd; parameters[13].Value = model.Mo; parameters[14].Value = model.MoAdd; parameters[15].Value = model.Cu; parameters[16].Value = model.CuAdd; parameters[17].Value = model.Mn; parameters[18].Value = model.MnAdd; parameters[19].Value = model.Fe; parameters[20].Value = model.FeAdd; parameters[21].Value = model.Co; parameters[22].Value = model.CoAdd; parameters[23].Value = model.Nb; parameters[24].Value = model.NbAdd; parameters[25].Value = model.Zr; parameters[26].Value = model.ZrAdd; parameters[27].Value = model.Ti; parameters[28].Value = model.TiAdd; parameters[29].Value = model.weight; parameters[30].Value = model.pullReportFileId; parameters[31].Value = model.otherData; parameters[32].Value = model.isrtEmpId; parameters[33].Value = model.isrtDt == string.Empty ? null : model.isrtDt; parameters[34].Value = model.updtEmpId; parameters[35].Value = model.updtDt == string.Empty ? null : model.updtDt; int id = 0; try { object ret = SqlHelper.ExecuteScalar(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); if (ret != null && ret != DBNull.Value) { id = Convert.ToInt32(ret); } } catch (Exception ex) { throw ex; } return id; }
public bool SaveProductCheckDetail(int checkDetailId, string strBoxNo, string strCheckResult, int noPassReasonId, string strCheckMark, string strCheckDt, int checkGunId, int checkGunIndex, float weight, string strOtherData, string strCheckItemNo, string strMaterialNo, int empId) { BProductCheckDetailBC productCheckDetailBC = new BProductCheckDetailBC(); try { //产品检测结果实例赋值 BProductCheckDetailData productCheckDetailModel = new BProductCheckDetailData(); productCheckDetailModel.checkDetailId = checkDetailId;//检测单明细ID productCheckDetailModel.boxNo = strBoxNo;//箱号 productCheckDetailModel.checkResult = strCheckResult;//检测结果 productCheckDetailModel.noPassReasonId = noPassReasonId;//不合格原因 productCheckDetailModel.checkMark = strCheckMark;//检验备注 productCheckDetailModel.checkDt = strCheckDt;//检测时间 productCheckDetailModel.checkGunId = checkGunId;//检测枪 productCheckDetailModel.checkGunIndex = checkGunIndex;//枪号 productCheckDetailModel.weight = weight;//称重重量 productCheckDetailModel.otherData = strOtherData;//其他检测数据 productCheckDetailModel.isrtEmpId = empId;//添加人员 productCheckDetailModel.isrtDt = System.DateTime.Now.ToString();//添加时间 //产品检测结果数据保存 productCheckDetailBC.EmpID = empId; productCheckDetailBC.SaveRecord(productCheckDetailModel, strCheckItemNo, strMaterialNo); return true; } finally { productCheckDetailBC.Dispose(); } }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model">model</param> public bool ModifyRecord(BProductCheckDetailData model) { bool ret = false; StringBuilder strSql = new StringBuilder(); strSql.Append("update BProductCheckDetail set "); strSql.Append("checkDetailId=@checkDetailId,"); strSql.Append("boxNo=@boxNo,"); strSql.Append("checkResult=@checkResult,"); strSql.Append("noPassReasonId=@noPassReasonId,"); strSql.Append("checkMark=@checkMark,"); strSql.Append("checkDt=@checkDt,"); strSql.Append("checkGunId=@checkGunId,"); strSql.Append("checkGunIndex=@checkGunIndex,"); strSql.Append("Match1=@Match1,"); strSql.Append("Cr=@Cr,"); strSql.Append("CrAdd=@CrAdd,"); strSql.Append("Ni=@Ni,"); strSql.Append("NiAdd=@NiAdd,"); strSql.Append("Mo=@Mo,"); strSql.Append("MoAdd=@MoAdd,"); strSql.Append("Cu=@Cu,"); strSql.Append("CuAdd=@CuAdd,"); strSql.Append("Mn=@Mn,"); strSql.Append("MnAdd=@MnAdd,"); strSql.Append("Fe=@Fe,"); strSql.Append("FeAdd=@FeAdd,"); strSql.Append("Co=@Co,"); strSql.Append("CoAdd=@CoAdd,"); strSql.Append("Nb=@Nb,"); strSql.Append("NbAdd=@NbAdd,"); strSql.Append("Zr=@Zr,"); strSql.Append("ZrAdd=@ZrAdd,"); strSql.Append("Ti=@Ti,"); strSql.Append("TiAdd=@TiAdd,"); strSql.Append("weight=@weight,"); strSql.Append("pullReportFileId=@pullReportFileId,"); strSql.Append("otherData=@otherData,"); strSql.Append("isrtEmpId=@isrtEmpId,"); strSql.Append("isrtDt=@isrtDt,"); strSql.Append("updtEmpId=@updtEmpId,"); strSql.Append("updtDt=@updtDt"); strSql.Append(" where id = @id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int), new SqlParameter("@checkDetailId", SqlDbType.Int), new SqlParameter("@boxNo", SqlDbType.VarChar,20), new SqlParameter("@checkResult", SqlDbType.NVarChar,20), new SqlParameter("@noPassReasonId", SqlDbType.Int), new SqlParameter("@checkMark", SqlDbType.NVarChar,200), new SqlParameter("@checkDt", SqlDbType.DateTime), new SqlParameter("@checkGunId", SqlDbType.Int), new SqlParameter("@checkGunIndex", SqlDbType.Int), new SqlParameter("@Match1", SqlDbType.NVarChar,20), new SqlParameter("@Cr", SqlDbType.NVarChar,20), new SqlParameter("@CrAdd", SqlDbType.NVarChar,20), new SqlParameter("@Ni", SqlDbType.NVarChar,20), new SqlParameter("@NiAdd", SqlDbType.NVarChar,20), new SqlParameter("@Mo", SqlDbType.NVarChar,20), new SqlParameter("@MoAdd", SqlDbType.NVarChar,20), new SqlParameter("@Cu", SqlDbType.NVarChar,20), new SqlParameter("@CuAdd", SqlDbType.NVarChar,20), new SqlParameter("@Mn", SqlDbType.NVarChar,20), new SqlParameter("@MnAdd", SqlDbType.NVarChar,20), new SqlParameter("@Fe", SqlDbType.NVarChar,20), new SqlParameter("@FeAdd", SqlDbType.NVarChar,20), new SqlParameter("@Co", SqlDbType.VarChar,20), new SqlParameter("@CoAdd", SqlDbType.VarChar,20), new SqlParameter("@Nb", SqlDbType.VarChar,20), new SqlParameter("@NbAdd", SqlDbType.VarChar,20), new SqlParameter("@Zr", SqlDbType.VarChar,20), new SqlParameter("@ZrAdd", SqlDbType.VarChar,20), new SqlParameter("@Ti", SqlDbType.VarChar,20), new SqlParameter("@TiAdd", SqlDbType.VarChar,20), new SqlParameter("@weight", SqlDbType.Float), new SqlParameter("@pullReportFileId", SqlDbType.Int), new SqlParameter("@otherData", SqlDbType.NVarChar,50), new SqlParameter("@isrtEmpId", SqlDbType.Int), new SqlParameter("@isrtDt", SqlDbType.DateTime), new SqlParameter("@updtEmpId", SqlDbType.Int), new SqlParameter("@updtDt", SqlDbType.DateTime) }; parameters[0].Value = model.id; parameters[1].Value = model.checkDetailId; parameters[2].Value = model.boxNo; parameters[3].Value = model.checkResult; parameters[4].Value = model.noPassReasonId; parameters[5].Value = model.checkMark; parameters[6].Value = model.checkDt == string.Empty ? null : model.checkDt; parameters[7].Value = model.checkGunId; parameters[8].Value = model.checkGunIndex; parameters[9].Value = model.Match1; parameters[10].Value = model.Cr; parameters[11].Value = model.CrAdd; parameters[12].Value = model.Ni; parameters[13].Value = model.NiAdd; parameters[14].Value = model.Mo; parameters[15].Value = model.MoAdd; parameters[16].Value = model.Cu; parameters[17].Value = model.CuAdd; parameters[18].Value = model.Mn; parameters[19].Value = model.MnAdd; parameters[20].Value = model.Fe; parameters[21].Value = model.FeAdd; parameters[22].Value = model.Co; parameters[23].Value = model.CoAdd; parameters[24].Value = model.Nb; parameters[25].Value = model.NbAdd; parameters[26].Value = model.Zr; parameters[27].Value = model.ZrAdd; parameters[28].Value = model.Ti; parameters[29].Value = model.TiAdd; parameters[30].Value = model.weight; parameters[31].Value = model.pullReportFileId; parameters[32].Value = model.otherData; parameters[33].Value = model.isrtEmpId; parameters[34].Value = model.isrtDt == string.Empty ? null : model.isrtDt; parameters[35].Value = model.updtEmpId; parameters[36].Value = model.updtDt == string.Empty ? null : model.updtDt; try { SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); ret = true; } catch (Exception ex) { throw ex; } return ret; }
/// <summary> /// 得到一个model /// </summary> /// <param name="id">主键值</param> /// <returns>model</returns> public BProductCheckDetailData GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append(@"select id,checkDetailId,boxNo,checkResult,noPassReasonId,checkMark,checkDt,checkGunId,checkGunIndex,Match1,Cr, CrAdd,Ni,NiAdd,Mo,MoAdd,Cu,CuAdd,Mn,MnAdd,Fe, FeAdd,Co,CoAdd,Nb,NbAdd,Zr,ZrAdd,Ti,TiAdd,weight, pullReportFileId,otherData,isrtEmpId,isrtDt,updtEmpId,updtDt from BProductCheckDetail"); strSql.Append(" where id = @id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int) }; parameters[0].Value = id; BProductCheckDetailData model = new BProductCheckDetailData(); DataSet ds = SqlHelper.ExecuteDataset(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { DataRow row = ds.Tables[0].Rows[0]; if (row["id"] != DBNull.Value) { model.id = Convert.ToInt32(row["id"]); } if (row["checkDetailId"] != DBNull.Value) { model.checkDetailId = Convert.ToInt32(row["checkDetailId"]); } if (row["boxNo"] != DBNull.Value) { model.boxNo = Convert.ToString(row["boxNo"]); } if (row["checkResult"] != DBNull.Value) { model.checkResult = Convert.ToString(row["checkResult"]); } if (row["noPassReasonId"] != DBNull.Value) { model.noPassReasonId = Convert.ToInt32(row["noPassReasonId"]); } if (row["checkMark"] != DBNull.Value) { model.checkMark = Convert.ToString(row["checkMark"]); } if (row["checkDt"] != DBNull.Value) { model.checkDt = Convert.ToString(row["checkDt"]); } if (row["checkGunId"] != DBNull.Value) { model.checkGunId = Convert.ToInt32(row["checkGunId"]); } if (row["checkGunIndex"] != DBNull.Value) { model.checkGunIndex = Convert.ToInt32(row["checkGunIndex"]); } if (row["Match1"] != DBNull.Value) { model.Match1 = Convert.ToString(row["Match1"]); } if (row["Cr"] != DBNull.Value) { model.Cr = Convert.ToString(row["Cr"]); } if (row["CrAdd"] != DBNull.Value) { model.CrAdd = Convert.ToString(row["CrAdd"]); } if (row["Ni"] != DBNull.Value) { model.Ni = Convert.ToString(row["Ni"]); } if (row["NiAdd"] != DBNull.Value) { model.NiAdd = Convert.ToString(row["NiAdd"]); } if (row["Mo"] != DBNull.Value) { model.Mo = Convert.ToString(row["Mo"]); } if (row["MoAdd"] != DBNull.Value) { model.MoAdd = Convert.ToString(row["MoAdd"]); } if (row["Cu"] != DBNull.Value) { model.Cu = Convert.ToString(row["Cu"]); } if (row["CuAdd"] != DBNull.Value) { model.CuAdd = Convert.ToString(row["CuAdd"]); } if (row["Mn"] != DBNull.Value) { model.Mn = Convert.ToString(row["Mn"]); } if (row["MnAdd"] != DBNull.Value) { model.MnAdd = Convert.ToString(row["MnAdd"]); } if (row["Fe"] != DBNull.Value) { model.Fe = Convert.ToString(row["Fe"]); } if (row["FeAdd"] != DBNull.Value) { model.FeAdd = Convert.ToString(row["FeAdd"]); } if (row["Co"] != DBNull.Value) { model.Co = Convert.ToString(row["Co"]); } if (row["CoAdd"] != DBNull.Value) { model.CoAdd = Convert.ToString(row["CoAdd"]); } if (row["Nb"] != DBNull.Value) { model.Nb = Convert.ToString(row["Nb"]); } if (row["NbAdd"] != DBNull.Value) { model.NbAdd = Convert.ToString(row["NbAdd"]); } if (row["Zr"] != DBNull.Value) { model.Zr = Convert.ToString(row["Zr"]); } if (row["ZrAdd"] != DBNull.Value) { model.ZrAdd = Convert.ToString(row["ZrAdd"]); } if (row["Ti"] != DBNull.Value) { model.Ti = Convert.ToString(row["Ti"]); } if (row["TiAdd"] != DBNull.Value) { model.TiAdd = Convert.ToString(row["TiAdd"]); } if (row["weight"] != DBNull.Value) { model.weight = Convert.ToDouble(row["weight"]); } if (row["pullReportFileId"] != DBNull.Value) { model.pullReportFileId = Convert.ToInt32(row["pullReportFileId"]); } if (row["otherData"] != DBNull.Value) { model.otherData = Convert.ToString(row["otherData"]); } if (row["isrtEmpId"] != DBNull.Value) { model.isrtEmpId = Convert.ToInt32(row["isrtEmpId"]); } if (row["isrtDt"] != DBNull.Value) { model.isrtDt = Convert.ToString(row["isrtDt"]); } if (row["updtEmpId"] != DBNull.Value) { model.updtEmpId = Convert.ToInt32(row["updtEmpId"]); } if (row["updtDt"] != DBNull.Value) { model.updtDt = Convert.ToString(row["updtDt"]); } return model; } else { return null; } }
//***************************************************************************** //do it later do it later do it later //***************************************************************************** /// <summary> /// 保存产品检测结果 /// </summary> /// <param name="productCheckDetailModel">产品检测结果实例</param> /// <returns></returns> public bool SaveRecord(BProductCheckDetailData productCheckDetailModel, string strCheckItemNo, string strMaterialNo) { bool ret = false; SqlTransaction trans = null; BWeigtHistoryBB weightHistoryBB = new BWeigtHistoryBB(this.connection); SCommBB commBB = new SCommBB(this.connection); try { if (this.transaction == null) { trans = this.connection.BeginTransaction("TransSave"); this.productCheckDetailBB.Transaction = trans; weightHistoryBB.Transaction = trans; commBB.Transaction = trans; } else { this.productCheckDetailBB.Transaction = this.transaction; weightHistoryBB.Transaction = this.transaction; commBB.Transaction = this.transaction; } StringBuilder strSql = new StringBuilder(); BWeigtHistoryData weightHistoryModel = new BWeigtHistoryData(); //保存产品检测结果实例 this.productCheckDetailBB.AddRecord(productCheckDetailModel); //更改产品检测单状态为“检测中” strSql.Append("update checkBill set instantState='03' "); strSql.Append("from dbo.BCheckBill as checkBill "); strSql.Append("left join dbo.BCheckDetail as checkDetail on checkDetail.checkBillId=checkBill.Id "); strSql.Append("where checkDetail.id=" + productCheckDetailModel.checkDetailId.ToString()); commBB.ExecuteSql(strSql.ToString()); //如果为称重,向称重记录表插入一条数据 if (strCheckItemNo == "1004") { weightHistoryModel.materialNo = strMaterialNo;//物料编号 weightHistoryModel.dt = productCheckDetailModel.checkDt;//称重时间 weightHistoryModel.weight = productCheckDetailModel.weight;//称重 weightHistoryModel.isrtDt = System.DateTime.Now.ToString();//添加时间 weightHistoryModel.isrtEmpId = this.empId;//添加人 weightHistoryBB.AddRecord(weightHistoryModel); } if (this.transaction == null) trans.Commit(); ret = true; } catch (Exception ex) { if (this.transaction == null) trans.Rollback("TransSave"); throw ex; } finally { weightHistoryBB.Dispose(); commBB.Dispose(); } return ret; }
/// <summary> /// 更新一条"物料检验单明细"信息 /// </summary> /// <param name="model">model</param> public bool ModifyRecord(BProductCheckDetailData model) { bool ret = false; SqlTransaction trans = null; try { if (this.transaction == null) { trans = this.connection.BeginTransaction("TransModify"); this.productCheckDetailBB.Transaction = trans; this.errorDiaryBB.Transaction = trans; this.operatDiaryBB.Transaction = trans; } this.productCheckDetailBB.ModifyRecord(model); SOperatDiaryData operatDiaryData = new SOperatDiaryData(); operatDiaryData.empId = this.empId; operatDiaryData.functionId = ""; operatDiaryData.recordId = model.id.ToString(); operatDiaryData.operateContent = "物料检验单明细修改一条id为“" + model.id.ToString() + "”的记录"; this.operatDiaryBB.AddRecord(operatDiaryData); if (this.transaction == null) trans.Commit(); ret = true; } catch (Exception ex) { if (this.transaction == null) trans.Rollback("TransModify"); SErrorDiaryData errorDiaryData = new SErrorDiaryData(); errorDiaryData.empId = this.empId; errorDiaryData.functionId = ""; errorDiaryData.errorText = "物料检验单明细修改记录“" + model.id.ToString() + "”时报错:" + ex.Message; this.errorDiaryBB.AddRecord(errorDiaryData); throw ex; } finally { } return ret; }
/// <summary> /// 增加一条"物料检验单明细"信息 /// </summary> /// <param name="model">model</param> public int AddRecord(BProductCheckDetailData model) { int id = 0; SqlTransaction trans = null; try { if (this.transaction == null) { trans = this.connection.BeginTransaction("TransAdd"); this.productCheckDetailBB.Transaction = trans; this.errorDiaryBB.Transaction = trans; this.operatDiaryBB.Transaction = trans; } id = this.productCheckDetailBB.AddRecord(model); SOperatDiaryData operatDiaryData = new SOperatDiaryData(); operatDiaryData.empId = this.empId; operatDiaryData.functionId = ""; operatDiaryData.recordId = id.ToString(); operatDiaryData.operateContent = "物料检验单明细增加一条id为“" + id.ToString() + "”的记录"; this.operatDiaryBB.AddRecord(operatDiaryData); if (this.transaction == null) trans.Commit(); } catch (Exception ex) { if (this.transaction == null) trans.Rollback("TransAdd"); SErrorDiaryData errorDiaryData = new SErrorDiaryData(); errorDiaryData.empId = this.empId; errorDiaryData.functionId = ""; errorDiaryData.errorText = "物料检验单明细增加记录时报错:" + ex.Message; this.errorDiaryBB.AddRecord(errorDiaryData); throw ex; } finally { } return id; }