/// <summary> /// 检查文件是否在PDM中 /// </summary> private bool CheckInPDM(string fileName) { //PDM根目录 string rootpath = PDMHelper.LoginPDM(); if (rootpath.Length > 0 && fileName.Length > 0) { if (fileName.Contains(rootpath))//判断文件是否是PDM中文件 { //获取文件在PDM中的ID Globals.FileID = PDMHelper.GetFileID(fileName).ToString(); return(true); } else { this.lblErrorInfo.Text = "请先将文件保存至PDM!"; return(false); } } else { this.lblErrorInfo.Text = "请先将文件保存至PDM!"; return(false); } }
//获取用户名BySQL(FullName) public static string GetLoginFullName(string PDMDbName) { SQLHelper.connString = Globals.connStrPDM; string loginId = PDMHelper.GetLoginID(); string sql = string.Format("select fullname from [{0}].dbo.Users where UserId='{1}'", PDMDbName, loginId); return(SQLHelper.GetSingleResult(sql).ToString()); }
/// <summary> /// 获取登录名ByPDM(UserName) /// </summary> /// <returns></returns> public static String GetLoginUserName() { string a = PDMHelper.GetLoginID(); DataTable dt = PDMHelper.GetUserList(); DataView dv = new DataView(dt); dv.RowFilter = string.Format(" UserId='{0}' ", a); return(dv.ToTable("default").Rows[0]["UserName"].ToString()); }
/// <summary> /// 获取并显示PDM登录信息 /// </summary> private void GetPDMLoginInfo() { //获取登录信息 Globals.UserID = PDMHelper.GetLoginID(); Globals.UserName = PDMHelper.GetLoginFullName(); //显示登录信息 this.lblUserName.ForeColor = Color.Black; this.lblUserName.Text = string.Format("当前用户:{0}({1})", Globals.DEF_CreateId, Globals.UserName); }
/// <summary> /// 初始化全局变量(即Globals中的变量) /// </summary> private void InitializeGlobalsVariables() { //获取SolidWorks文件名及文件ID Globals.FileName = swAppHelper.GetFileName(); Globals.FileID = PDMHelper.GetFileID(Globals.FileName).ToString(); //获取PDM登录信息 Globals.PDM_UserID = PDMHelper.GetLoginID(); Globals.PDM_UserAccount = PDMHelper.GetLoginUserName(); Globals.PDM_UserFullName = PDMHelper.GetLoginFullName(); }
//检查 private void btnCheck_Click(object sender, EventArgs e) { #region (三步验证)文件名、PDM登录、PDM内【暂无:检出状态、已有编码】 try { //验证1:检查是否正常获取文件名 if (Globals.FileName == null || Globals.FileName.Length == 0) { this.lblErrorInfo.Text = "该文件没有保存,无法获取文件名!"; Msg.ShowError(this.lblErrorInfo.Text); return; } //验证2:检查是否登录PDM系统 if (!PDMHelper.IsLoginPDM()) { this.lblErrorInfo.Text = "PDM未正常登录!"; Msg.ShowError(this.lblErrorInfo.Text); return; } //验证3:检查文件是否在PDM中 if (!CheckInPDM(Globals.FileName)) { this.lblErrorInfo.Text = "该文件没有保存到PDM中!"; Msg.ShowError(this.lblErrorInfo.Text); return; } //验证4:检查文件是否在PDM中检出(暂时不验证) //if (!PDMHelper.IsLock(Globals.FileName)) //{ // this.lblErrorInfo.Text = "该文件没有在PDM中检出!"; // return; //} //验证5:检查文件ID是否已经有图号信息,如果有则覆盖 //if (ExistedMaterialCode()) //{ // this.lblErrorInfo.Text = "该文件的图号编码已经存在!"; // return; //} } catch (Exception ex) { this.lblErrorInfo.ForeColor = Color.Red; this.lblErrorInfo.Text = "PDM未正常登录!"; Msg.ShowError(ex.Message); return; } this.DialogResult = DialogResult.OK; #endregion }
/// <summary> /// 构造方法 /// </summary> public frmDrawingCode() { InitializeComponent(); try { #region 拉框数据初始化 this.cboDrawingClass.SelectedIndexChanged -= new System.EventHandler(this.cboDrawingClass_SelectedIndexChanged); //初始化图号分类下拉框 List <DrawingClassModel> dclasslist = objDrawingService.GetDrawingClass(); this.cboDrawingClass.DataSource = dclasslist; this.cboDrawingClass.ValueMember = "DrawingClassId"; this.cboDrawingClass.DisplayMember = "DrawingClassName"; this.cboDrawingClass.SelectedIndex = -1; //初始化主单位下拉框 List <UnitModel> unitlist = objDrawingService.GetUnit(); this.cboUnit.DataSource = unitlist; this.cboUnit.ValueMember = "UnitCode"; this.cboUnit.DisplayMember = "UnitName"; this.cboUnit.SelectedIndex = -1; ////初始化采购分类下拉框 //List<PurchaseTypeModel> purchaselist = objDrawingService.GetPurchaseType(); //this.cboPurchaseType.DataSource = purchaselist; //this.cboPurchaseType.ValueMember = "PurchaseTypeId"; //this.cboPurchaseType.DisplayMember = "PurchaseTypeName"; //this.cboPurchaseType.SelectedIndex = -1; //初始化选型分类下拉框 List <SelectionTypeModel> selectionlist = objDrawingService.GetSelectionType(); this.cboSelectionType.DataSource = selectionlist; this.cboSelectionType.ValueMember = "SelectionTypeId"; this.cboSelectionType.DisplayMember = "SelectionTypeName"; this.cboSelectionType.SelectedIndex = -1; this.cboDrawingClass.SelectedIndexChanged += new System.EventHandler(this.cboDrawingClass_SelectedIndexChanged); #endregion //获取文件名及文件ID Globals.FileName = swAppHelper.GetFileName(); Globals.FileID = PDMHelper.GetFileID(Globals.FileName).ToString(); this.btnAddMaterial.Enabled = true;//启动提交数据按钮 ShowPDMInfo(); DefaultWorking(); } catch (Exception ex) { Msg.ShowError(ex.Message); } }
//登录PDM库视图 private void btnLogin_Click(object sender, EventArgs e) { try { if (!PDMHelper.IsLoginPDM()) { Msg.ShowInformation("请先登录PDM系统!"); return; } else { //获取并显示PDM登录信息 GetPDMLoginInfo(); } } catch (Exception ex) { this.lblUserName.ForeColor = Color.Red; this.lblUserName.Text = "PDM未正常登录!"; Msg.ShowError(ex.Message); } }