private DbCommand GetPdfFileCommand(XVEquipmentReceiveInfo receiveInfo) { string fileDesc = string.Empty; string fileName = receiveInfo.PdfReportFileFullName; FileInfo fi = new FileInfo(fileName); double fileSize = 0; fileSize = Math.Round(XHelper.GetDouble(fi.Length) / XHelper.GetDouble(1024), 2); byte[] bData = XHelper.GetFileBytes(fileName); string fileId = receiveInfo.RID; string sql = "DELETE FROM EquipmentPDFReport WHERE FileId='" + fileId + "';"; sql += "INSERT INTO EquipmentPDFReport (RID,FileId,AtchName,AtchDesc,AtchType," + "AtchSize,AtchPath,AtchShotGifPath,AtchImag,InputUserId,InputTime)values" + "(@RId,@FileId,@AtchName,@AtchDesc,@AtchType,@AtchSize,@AtchPath,@AtchShotGifPath," + "@AtchImag,@UserId,getdate())"; DbConnection conn = this.m_DataAccess.Connection; DbCommand cmd = this.m_DataAccess.GetDbCommand(); cmd.CommandText = sql; DbParameter parameterId = this.m_DataAccess.GetParameter("@RId", Guid.NewGuid().ToString()); cmd.Parameters.Add(parameterId); DbParameter parameterMainId = this.m_DataAccess.GetParameter("@FileId", fileId); cmd.Parameters.Add(parameterMainId); DbParameter parameterFileName = this.m_DataAccess.GetParameter("@AtchName", fi.Name); cmd.Parameters.Add(parameterFileName); DbParameter parameterAtchDesc = this.m_DataAccess.GetParameter("@AtchDesc", fileDesc); cmd.Parameters.Add(parameterAtchDesc); DbParameter parameterAtchType = this.m_DataAccess.GetParameter("@AtchType", fi.Extension); cmd.Parameters.Add(parameterAtchType); DbParameter parameterAtchSize = this.m_DataAccess.GetParameter("@AtchSize", fileSize); cmd.Parameters.Add(parameterAtchSize); DbParameter parameterAtchPath = this.m_DataAccess.GetParameter("@AtchPath", fi.FullName); cmd.Parameters.Add(parameterAtchPath); DbParameter parameterAtchShotGifPath = this.m_DataAccess.GetParameter("@AtchShotGifPath", ""); cmd.Parameters.Add(parameterAtchShotGifPath); DbParameter parameterFile = this.m_DataAccess.GetParameter("@AtchImag", bData); cmd.Parameters.Add(parameterFile); DbParameter parameterUser = this.m_DataAccess.GetParameter("@UserId", receiveInfo.UpdateUserId); cmd.Parameters.Add(parameterUser); return(cmd); }
private static void FillRange(Word.Document dct, Word.Bookmark bookMark, XVEquipmentReceiveInfo receiveInfo) { string userId = string.Empty; string userName = string.Empty; switch (bookMark.Name) { case "检定员": userId = receiveInfo.CheckedUserId; userName = receiveInfo.CheckedUserName; // bookMark.Range.Text = receiveInfo.CheckedUserName; break; case "核验员": userId = receiveInfo.VerifyedUserId; userName = receiveInfo.VerifyedUserName; //bookMark.Range.Text = receiveInfo.VerifyedUserName; break; case "签发员": userId = receiveInfo.SignedUserId; userName = receiveInfo.SignedUserName; //bookMark.Range.Text = receiveInfo.SignedUserName; break; case "收发员": userId = receiveInfo.DispatchUserId; userName = receiveInfo.DispatchUserName; //bookMark.Range.Text = receiveInfo.DispatchUserName; break; } FillRangeByReceiveInfo(dct, bookMark, userId, userName); }
protected override void SetDefaultValue() { XVEquipmentReceiveInfo info = this.m_CurrentModel as XVEquipmentReceiveInfo; if (info.EquipmentCheckId != string.Empty) { this.txtEquipmentCheckId.Text = info.EquipmentName; this.txtEquipmentCheckId.DisplayMember = info.EquipmentName; this.txtEquipmentCheckId.ValueMember = info.EquipmentCheckId; } this.cboEquipmentType.Text = info.EquipmentTypeName; this.txtEquipmentNo.Text = info.EquipmentNo; this.txtEquipmentCustId.Text = info.CustName; this.txtSpec.Text = info.Spec; this.txtModel.Text = info.Model; this.nebQuanlity.Value = info.Quanlity; //this.dtLastCheckDate.Value = XHelper.GetDateTime(info.LastCheckDate); this.cboSourceTypeId.Text = info.SourceTypeId; //this.txtSourceCustId.Text = info.SourceCustId; this.dtSourceTime.Value = XHelper.GetDateTime(info.SourceTime); //2016-03-39,mxj,add========================== this.dtCheckedDate.Value = XHelper.GetDateTime(info.CheckedDate); //============================================ this.txtReceiveDesc.Text = info.ReceiveDesc; this.txtReceiveUser.Text = info.ReceiveUserName; this.txtCheckedDesc.Text = info.CheckedDesc; //指定签收员 if (info.SignUserId != string.Empty) { this.txtSignUserId.ValueMember = info.SignUserId; this.txtSignUserId.DisplayMember = info.SignUserName; this.txtSignUserId.Text = info.SignUserName; } //核验时间 if (XHelper.GetDateTime(info.VerifyedDate).Date == new DateTime(2000, 1, 1).Date) { this.dtVerifyedDate.Value = DateTime.Now; } else { this.dtVerifyedDate.Value = XHelper.GetDateTime(info.VerifyedDate); } //核验描述 this.txtVerifyedDesc.Text = info.VerifyedDesc; //检定员 this.txtCheckedUserName.Text = info.CheckedUserName; this.txtFactoryName.Text = info.FactoryName; this.txtFactoryNo.Text = info.FactoryNo; this.txtCheckAccord.Text = info.CheckAccord; }
public frmPrintPreview(XVEquipmentReceiveInfo receiveInfo, bool isAllowPrint) { InitializeComponent(); this.m_EquipmentReceiveInfo = receiveInfo; this.Init(); if (!isAllowPrint) { this.btnPrint.Enabled = false; } }
/// <summary> /// 制证 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool PrintBill(XModelBase model) { XVEquipmentReceiveInfo receiveInfo = model as XVEquipmentReceiveInfo; string sql = "UPDATE " + this.TableName + " SET UpdateTime=getdate(),UpdateUserId='" + receiveInfo.UpdateUserId + "', " + "CurrentStatus='制证',FlowStatus='制证'," + "FlowUserId='" + receiveInfo.UpdateUserId + "' " + " WHERE RID='" + model.ID + "'"; return(this.m_DataAccess.ExecuteNonQuery(sql) > 0); }
public bool Verify(XModelBase model, string userId) { XVEquipmentReceiveInfo receiveInfo = model as XVEquipmentReceiveInfo; string sql = "UPDATE " + this.TableName + " SET VerifyedUserId='" + userId + "',VerifyedDate='" + receiveInfo.VerifyedDate + "',VerifyedDesc='" + receiveInfo.VerifyedDesc + "'," + "CurrentStatus='" + receiveInfo.CurrentStatus + "',FlowStatus='" + receiveInfo.FlowStatus + "'," + "FlowUserId='" + receiveInfo.VerifyUserId + "',SignUserId='" + receiveInfo.SignUserId + "'" + " WHERE RID='" + model.ID + "'"; return(this.m_DataAccess.ExecuteNonQuery(sql) > 0); }
/// <summary> /// 退回重新检定 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Back(XModelBase model) { XVEquipmentReceiveInfo receiveInfo = model as XVEquipmentReceiveInfo; string sql = "UPDATE " + this.TableName + " SET IsBack=1,BackDate=getdate()," + "BackReason='" + receiveInfo.BackReason + "'," + "BackStatus='" + receiveInfo.BackStatus + "',BackUserId='" + receiveInfo.BackUserId + "', " + "CurrentStatus='接收',FlowStatus='检定'," + "FlowUserId=CheckUserId " + " WHERE RID='" + model.ID + "'"; return(this.m_DataAccess.ExecuteNonQuery(sql) > 0); }
protected override void FillModelInfo() { XVEquipmentReceiveInfo info = this.m_CurrentModel as XVEquipmentReceiveInfo; info.SignUserId = this.txtSignUserId.ValueMember; info.SignUserName = this.txtSignUserId.DisplayMember; info.VerifyedDate = XHelper.GetFormatedDate(this.dtVerifyedDate.Value); info.VerifyedDesc = this.txtVerifyedDesc.Text.Trim(); info.CurrentStatus = "核验"; info.FlowStatus = "签发"; info.IsBack = this.chkIsBack.Checked; info.BackReason = this.txtBackReason.Text.Trim(); info.BackUserId = XCommon.LoginUsersInfo.RID; info.BackStatus = info.CurrentStatus; }
public static void FillWordValue(string fileFullName, XVEquipmentReceiveInfo receiveInfo) { Word.Application app = new Word.Application(); app.Visible = false; Word.Document document = app.Documents.Open(fileFullName); for (int i = 1; i <= document.Bookmarks.Count; i++) { Word.Bookmark bookMark = document.Bookmarks[i]; FillRange(document, bookMark, receiveInfo); } document.Save(); document.Close(); app.Quit(null, null, null); }
protected override void SetDefaultValue() { XVEquipmentReceiveInfo info = this.m_CurrentModel as XVEquipmentReceiveInfo; if (info.EquipmentCheckId != string.Empty) { this.txtEquipmentCheckId.Text = info.EquipmentName; this.txtEquipmentCheckId.DisplayMember = info.EquipmentName; this.txtEquipmentCheckId.ValueMember = info.EquipmentCheckId; } this.cboEquipmentType.Text = info.EquipmentType; this.txtEquipmentNo.Text = info.EquipmentNo; this.txtEquipmentCustId.Text = info.CustName; this.txtSpec.Text = info.Spec; this.txtModel.Text = info.Model; this.nebQuanlity.Value = info.Quanlity; //this.dtLastCheckDate.Value = XHelper.GetDateTime(info.LastCheckDate); this.cboSourceTypeId.Text = info.SourceTypeId; //this.txtSourceCustId.Text = info.SourceCustId; this.dtSourceTime.Value = XHelper.GetDateTime(info.SourceTime); this.txtReceiveDesc.Text = info.ReceiveDesc; this.txtReceiveUser.Text = info.ReceiveUserName; this.txtCheckedDesc.Text = info.CheckedDesc; //签发描述 this.txtSignedDesc.Text = info.SignedDesc; //检定员 this.txtCheckedUserName.Text = info.CheckedUserName; //核验员 this.txtVerifyUserName.Text = info.VerifyedUserName; //核验描述 this.txtVerifyDesc.Text = info.VerifyedDesc; //签发员 this.txtSignedUserName.Text = info.SignedUserName; //收发员 this.txtDispatchUserName.Text = XCommon.LoginUsersInfo.RealName; this.txtFactoryName.Text = info.FactoryName; this.txtFactoryNo.Text = info.FactoryNo; this.txtCheckAccord.Text = info.CheckAccord; }
protected override void Print() { if (this.grdData.CurrentRow != null && this.grdData.CurrentRow.RowType == Janus.Windows.GridEX.RowType.Record) { XVEquipmentReceiveInfo receiveInfo = this.grdData.CurrentRow.DataRow as XVEquipmentReceiveInfo; if (!this.m_FileAttachBusiness.IsFileExist(receiveInfo.RID)) { XMessageBox.ShowError("未找到要打印的报告文档,请确认是否已上传报告!"); return; } frmPrintPreview frm = new frmPrintPreview(receiveInfo, true); frm.ShowDialog(); } }
/// <summary> /// 自动填充设备接收信息 /// </summary> /// <param name="check"></param> /// <returns></returns> public XVEquipmentReceiveInfo FillEquipmentReceiveInfo4Add(XVEquipmentCheckInfo check, string userId) { XVEquipmentReceiveInfo rev = new XVEquipmentReceiveInfo(); rev.EquipmentCheckId = check.RID; rev.EquipmentName = check.EquipmentName; rev.CheckUserId = check.SourceCustId; rev.CheckUserName = check.CheckResult;//字段临时借用:指定检定人名称 rev.Remark = "自动接收"; rev.RID = Guid.NewGuid().ToString(); rev.ID = check.RID; rev.EquipmentType = check.EquipmentTypeName; rev.EquipmentNo = check.EquipmentNo; rev.CustName = check.CustName; rev.Spec = check.Spec; rev.Model = check.Model; rev.Quanlity = check.Quanlity; rev.LastCheckDate = check.LastCheckDate; rev.SourceTypeId = check.SourceTypeId; rev.SourceCustId = check.SourceCustId; rev.SourceTime = check.SourceTime; rev.ReceiveDate = check.UseTime; rev.ReceiveDesc = check.EquipmentDesc; rev.ReceiveUserId = userId; //info.ReceiveUserName = XCommon.LoginUsersInfo.UserName; rev.CurrentStatus = "接收"; rev.FlowUserId = rev.CheckUserId; rev.FlowStatus = "检定"; rev.InputUserId = userId; rev.InputTime = XHelper.GetFormatedTime(DateTime.Now); rev.UpdateUserId = userId; rev.UpdateTime = XHelper.GetFormatedTime(DateTime.Now); rev.ModelStatus = XModelStatus.Add; return(rev); }
/// <summary> /// 填充实体信息 /// </summary> protected override void FillModelInfo() { XVEquipmentReceiveInfo info = this.m_CurrentModel as XVEquipmentReceiveInfo; info.EquipmentCheckId = this.txtEquipmentCheckId.ValueMember; info.EquipmentName = this.txtEquipmentCheckId.DisplayMember; info.CheckUserId = this.txtCheckUserId.ValueMember; info.CheckUserName = this.txtCheckUserId.DisplayMember; info.Remark = this.txtRemark.Text; if (this.m_EditStatus == XEditStatus.AddNew) { info.RID = this.GetNewId(); info.ID = info.RID; } info.EquipmentType = this.cboEquipmentType.Text; info.EquipmentNo = this.txtEquipmentNo.Text; info.CustName = this.txtEquipmentCustId.Text; info.Spec = this.txtSpec.Text; info.Model = this.txtModel.Text; info.Quanlity = XHelper.GetInt(this.nebQuanlity.Value); info.LastCheckDate = XHelper.GetFormatedDate(this.dtLastCheckDate.Value); info.SourceTypeId = this.cboSourceTypeId.Text; info.SourceCustId = this.txtSourceCustId.Text; info.SourceTime = XHelper.GetFormatedDate(this.dtSourceTime.Value); info.ReceiveDate = XHelper.GetFormatedDate(this.dtReceive.Value); info.ReceiveDesc = this.txtReceiveDesc.Text.Trim(); info.ReceiveUserId = XCommon.LoginUsersInfo.RID; //info.ReceiveUserName = XCommon.LoginUsersInfo.UserName; info.CurrentStatus = "接收"; info.FlowUserId = this.txtCheckUserId.ValueMember; info.FlowStatus = "检定"; base.FillModelInfo(); }
protected override void FillModelInfo() { XVEquipmentReceiveInfo info = this.m_CurrentModel as XVEquipmentReceiveInfo; info.CheckedDesc = this.txtCheckedDesc.Text.Trim(); info.CheckedReport = this.txtCheckedReport.Text.Trim(); info.VerifyUserId = this.txtVerifyUserId.ValueMember; info.VerifyUserName = this.txtVerifyUserId.DisplayMember; info.CheckedDate = XHelper.GetFormatedDate(this.dtCheckedDate.Value); info.CurrentStatus = "检定"; info.FlowStatus = "核验"; info.StandId = this.txtStandId.ValueMember; info.StandName = this.txtStandId.DisplayMember; info.IsBack = false; info.BackDate = string.Empty; info.BackReason = string.Empty; info.BackUserName = string.Empty; info.BackUserId = string.Empty; info.ReportFileFullName = this.txtFilePath.Text.Trim(); }
void cmdPdf_Click(object sender, Janus.Windows.UI.CommandBars.CommandEventArgs e) { if (this.grdData.CurrentRow != null && this.grdData.CurrentRow.RowType == Janus.Windows.GridEX.RowType.Record) { XVEquipmentReceiveInfo receiveInfo = this.grdData.CurrentRow.DataRow as XVEquipmentReceiveInfo; if (!this.m_PdfAttachBusiness.IsFileExist(receiveInfo.RID)) { XMessageBox.ShowError("未找到要打印的PDF文档,请确认是否已上传PDF报告!"); return; } string path = XCommon.TempPath; string tempFileName = Guid.NewGuid().ToString(); tempFileName = this.m_PdfAttachBusiness.DownLoadFile(receiveInfo.ID, path, tempFileName); if (tempFileName != string.Empty) { try { Process.Start(tempFileName); } catch (Exception ex) { XMessageBox.ShowError(ex.Message); XErrorLogTool.WriteLog(ex.ToString()); } } else { XMessageBox.ShowError("未找到要打印的PDF报告文档!"); this.Close(); } } }
protected override void FillRowViewInfos(XModelBase model, System.Data.DataRow modelRow) { XVEquipmentReceiveInfo info = model as XVEquipmentReceiveInfo; info.EquipmentType = XHelper.GetString(modelRow["EquipmentType"]); info.EquipmentCustId = XHelper.GetString(modelRow["EquipmentCustId"]); info.EquipmentName = XHelper.GetString(modelRow["EquipmentName"]); info.FactoryNo = XHelper.GetString(modelRow["FactoryNo"]); info.Spec = XHelper.GetString(modelRow["Spec"]); info.Model = XHelper.GetString(modelRow["Model"]); info.FactoryName = XHelper.GetString(modelRow["FactoryName"]); info.SourceTime = XHelper.GetString(modelRow["SourceTime"]); info.UseTime = XHelper.GetString(modelRow["UseTime"]); info.SourceCustId = XHelper.GetString(modelRow["SourceCustId"]); info.SourceTypeId = XHelper.GetString(modelRow["SourceTypeId"]); info.EquipmentStatusId = XHelper.GetString(modelRow["EquipmentStatusId"]); info.EquipmentNo = XHelper.GetString(modelRow["EquipmentNo"]); info.CustName = XHelper.GetString(modelRow["CustName"]); info.Quanlity = XHelper.GetInt(modelRow["Quanlity"]); info.LastCheckDate = XHelper.GetString(modelRow["LastCheckDate"]); info.EquipmentDesc = XHelper.GetString(modelRow["EquipmentDesc"]); info.CheckUserName = XHelper.GetString(modelRow["CheckUserName"]); info.ReceiveUserName = XHelper.GetString(modelRow["ReceiveUserName"]); info.VerifyUserName = XHelper.GetString(modelRow["VerifyUserName"]); info.SignUserName = XHelper.GetString(modelRow["SignUserName"]); info.VerifyedUserName = XHelper.GetString(modelRow["VerifyedUserName"]); info.CheckedUserName = XHelper.GetString(modelRow["CheckedUserName"]); info.DispatchUserName = XHelper.GetString(modelRow["DispatchUserName"]); info.SignedUserName = XHelper.GetString(modelRow["SignedUserName"]); info.BackUserName = XHelper.GetString(modelRow["BackUserName"]); info.StandName = XHelper.GetString(modelRow["StandName"]); info.CheckAccord = XHelper.GetString(modelRow["CheckAccord"]); info.EquipmentTypeName = XHelper.GetString(modelRow["EquipmentTypeName"]); //2014-12-19,mxj,add info.InvoiceNo = XHelper.GetString(modelRow["InvoiceNo"]); info.InvoiceFlag = XHelper.GetString(modelRow["InvoiceFlag"]); }
protected override void FillModelInfo() { XVEquipmentReceiveInfo info = this.m_CurrentModel as XVEquipmentReceiveInfo; info.DispatchUserId = this.txtDispatchUserId.ValueMember; info.DispatchUserName = this.txtDispatchUserId.DisplayMember; info.SignedDate = XHelper.GetFormatedDate(this.dtSignedDate.Value); info.SignedDesc = this.txtSignedDesc.Text.Trim(); info.CurrentStatus = "签发"; info.FlowStatus = "制证"; if (this.txtFilePath.Text.Trim() != string.Empty) { FileInfo fileInfo = new FileInfo(this.txtFilePath.Text.Trim()); info.PdfReportFileName = fileInfo.Name; } info.PdfReportFileFullName = this.txtFilePath.Text.Trim(); info.IsBack = this.chkIsBack.Checked; info.BackReason = this.txtBackReason.Text.Trim(); info.BackUserId = XCommon.LoginUsersInfo.RID; info.BackStatus = info.CurrentStatus; }
/// <summary> /// 设置修改时的默认值 /// </summary> protected override void SetDefaultValue() { XVEquipmentReceiveInfo info = this.m_CurrentModel as XVEquipmentReceiveInfo; if (info.EquipmentCheckId != string.Empty) { this.txtEquipmentCheckId.Text = info.EquipmentName; this.txtEquipmentCheckId.DisplayMember = info.EquipmentName; this.txtEquipmentCheckId.ValueMember = info.EquipmentCheckId; } if (info.CheckUserId != string.Empty) { this.txtCheckUserId.Text = info.CheckUserName; this.txtCheckUserId.ValueMember = info.CheckUserId; this.txtCheckUserId.DisplayMember = info.CheckUserName; } this.txtRemark.Text = info.Remark; this.cboEquipmentType.Text = info.EquipmentTypeName; this.txtEquipmentNo.Text = info.EquipmentNo; this.txtEquipmentCustId.Text = info.CustName; this.txtSpec.Text = info.Spec; this.txtModel.Text = info.Model; this.nebQuanlity.Value = info.Quanlity; this.dtLastCheckDate.Value = XHelper.GetDateTime(info.LastCheckDate); this.cboSourceTypeId.Text = info.SourceTypeId; this.txtSourceCustId.Text = info.SourceCustId; this.dtSourceTime.Value = XHelper.GetDateTime(info.SourceTime); this.dtReceive.Value = XHelper.GetDateTime(info.ReceiveDate); this.txtReceiveDesc.Text = info.ReceiveDesc; this.txtFactoryName.Text = info.FactoryName; this.txtFactoryNo.Text = info.FactoryNo; this.txtCheckAccord.Text = info.CheckAccord; }
public bool Checked(XModelBase model, string userId) { DbConnection sqlConn = this.m_DataAccess.Connection; DbTransaction trans = null; try { if (sqlConn.State == ConnectionState.Closed) { sqlConn.Open(); } trans = sqlConn.BeginTransaction(); string sql = string.Empty; XEquipmentCheckInfo info = model as XEquipmentCheckInfo; sql = "Insert Into " + this.TableName + "(RID,EquipmentType,EquipmentCustId,EquipmentName,FactoryNo,Spec,Model,FactoryName,SourceTime,UseTime,SourceCustId,SourceTypeId,EquipmentStatusId,SignStatus,Quanlity,LinkMan,Tel,Email,CheckAccord,LastCheckDate,CheckResult,ValidDate,CertNo,EquipmentDesc,Remark,InputUserId,InputTime,UpdateUserId,UpdateTime,EquipmentNo,BillNo)Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}',{14},'{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}','{23}','{24}','{25}',{26},'{27}',{28},'{29}','{30}')"; sql = String.Format(sql, info.RID, info.EquipmentType, info.EquipmentCustId, info.EquipmentName, info.FactoryNo, info.Spec, info.Model, info.FactoryName, info.SourceTime, info.UseTime, info.SourceCustId, info.SourceTypeId, info.EquipmentStatusId, info.SignStatus, info.Quanlity, info.LinkMan, info.Tel, info.Email, info.CheckAccord, info.LastCheckDate, info.CheckResult, info.ValidDate, info.CertNo, info.EquipmentDesc, info.Remark, info.InputUserId, this.GetServerTimeFuncion(), info.UpdateUserId, this.GetServerTimeFuncion(), info.EquipmentNo, info.BillNo); //if (receiveInfo.ReportFileFullName != string.Empty) //{ // //上传附件 // DbCommand fileCommand = this.GetFileCommand(receiveInfo); // fileCommand.Connection = sqlConn; // fileCommand.Transaction = trans; // DbDataReader reader = fileCommand.ExecuteReader(); // reader.Close(); //} sql += ";"; //XEquipmentReceiveInfo inforev = modelrev as XEquipmentReceiveInfo; XVEquipmentReceiveInfo inforev = FillEquipmentReceiveInfo4Add(model as XVEquipmentCheckInfo, userId); string sql2 = GetInsertSql4rev(inforev); sql = sql + sql2; DbCommand cmd = this.m_DataAccess.GetDbCommand(); cmd.Connection = sqlConn; cmd.CommandText = sql; cmd.Transaction = trans; bool isSuccess = cmd.ExecuteNonQuery() > 0; trans.Commit(); return(isSuccess); } catch (Exception ex) { XMessageBox.ShowError(ex.Message); XErrorLogTool.WriteLog(ex.ToString()); trans.Rollback(); } finally { if (sqlConn.State == ConnectionState.Open) { sqlConn.Close(); } } return(false); }
/// <summary> /// 检定 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Checked(XModelBase model, string userId) { DbConnection sqlConn = this.m_DataAccess.Connection; DbTransaction trans = null; try { if (sqlConn.State == ConnectionState.Closed) { sqlConn.Open(); } trans = sqlConn.BeginTransaction(); string sql = string.Empty; XVEquipmentReceiveInfo receiveInfo = model as XVEquipmentReceiveInfo; //更新检定信息 sql = "UPDATE " + this.TableName + " SET VerifyUserId='" + receiveInfo.VerifyUserId + "',CheckedReport='" + receiveInfo.CheckedReport + "',CheckedUserId='" + userId + "'," + "CheckedDate='" + receiveInfo.CheckedDate + "',CheckedDesc='" + receiveInfo.CheckedDesc + "', " + "CurrentStatus='" + receiveInfo.CurrentStatus + "',FlowStatus='" + receiveInfo.FlowStatus + "', " + "FlowUserId='" + receiveInfo.VerifyUserId + "', " + "IsBack=0,BackUserId=NULL,BackDate=null,BackReason=NULL,StandId='" + receiveInfo.StandId + "' " + "WHERE RID='" + receiveInfo.RID + "';"; if (receiveInfo.ReportFileFullName != string.Empty) { //上传附件 DbCommand fileCommand = this.GetFileCommand(receiveInfo); fileCommand.Connection = sqlConn; fileCommand.Transaction = trans; DbDataReader reader = fileCommand.ExecuteReader(); reader.Close(); } DbCommand cmd = this.m_DataAccess.GetDbCommand(); cmd.Connection = sqlConn; cmd.CommandText = sql; cmd.Transaction = trans; bool isSuccess = cmd.ExecuteNonQuery() > 0; trans.Commit(); return(isSuccess); } catch (Exception ex) { XMessageBox.ShowError(ex.Message); XErrorLogTool.WriteLog(ex.ToString()); trans.Rollback(); } finally { if (sqlConn.State == ConnectionState.Open) { sqlConn.Close(); } } return(false); }
protected override void SetDefaultValue() { XVEquipmentReceiveInfo info = this.m_CurrentModel as XVEquipmentReceiveInfo; if (info.EquipmentCheckId != string.Empty) { this.txtEquipmentCheckId.Text = info.EquipmentName; this.txtEquipmentCheckId.DisplayMember = info.EquipmentName; this.txtEquipmentCheckId.ValueMember = info.EquipmentCheckId; } this.cboEquipmentType.Text = info.EquipmentTypeName; this.txtEquipmentNo.Text = info.EquipmentNo; this.txtEquipmentCustId.Text = info.CustName; this.txtSpec.Text = info.Spec; this.txtModel.Text = info.Model; this.nebQuanlity.Value = info.Quanlity; //this.dtLastCheckDate.Value = XHelper.GetDateTime(info.LastCheckDate); this.cboSourceTypeId.Text = info.SourceTypeId; //this.txtSourceCustId.Text = info.SourceCustId; this.dtSourceTime.Value = XHelper.GetDateTime(info.SourceTime); //2016-03-39,mxj,add========================== this.dtReceiveDate.Value = XHelper.GetDateTime(info.ReceiveDate); //============================================ if (XHelper.GetDateTime(info.CheckedDate).Date == new DateTime(2000, 1, 1).Date) { this.dtCheckedDate.Value = DateTime.Now; } else { this.dtCheckedDate.Value = XHelper.GetDateTime(info.CheckedDate); } this.txtReceiveDesc.Text = info.ReceiveDesc; this.txtReceiveUser.Text = info.ReceiveUserName; if (info.VerifyUserId != string.Empty) { this.txtVerifyUserId.Text = info.VerifyUserName; this.txtVerifyUserId.DisplayMember = info.VerifyUserName; this.txtVerifyUserId.ValueMember = info.VerifyUserId; } if (info.StandId != string.Empty) { this.txtStandId.Text = info.StandName; this.txtStandId.ValueMember = info.StandId; this.txtStandId.DisplayMember = info.StandName; } else { //20151019,mxj,add if (info.CurrentStatus == "接收") { string sqlget = "select * from CodeEquipmentType where rid='" + info.EquipmentType + "'"; DataTable dt = new DataTable(); dt = SQLHelper.GetDataSet(sqlget); bool ishad = false; if (dt != null) { if (dt.Rows.Count > 0) { ishad = true; } } string disname = ""; string val = ""; if (ishad) { disname = dt.Rows[0]["SpellHeader"] + ""; val = dt.Rows[0]["Spell"] + ""; this.txtStandId.Text = disname; this.txtStandId.ValueMember = val; this.txtStandId.DisplayMember = disname; } } } this.txtCheckedReport.Text = info.CheckedReport; this.txtCheckedDesc.Text = info.CheckedDesc; this.txtFactoryName.Text = info.FactoryName; this.txtFactoryNo.Text = info.FactoryNo; this.txtCheckAccord.Text = info.CheckAccord; }