} // 0 - Раздел не материал, 1 - Раздел материал // public List <MatName> GetCustomProperty(string confname, SldWorks swApp) { var customnamelist = new List <MatName>(); try { customnamelist.Clear(); if (swApp == null) { swApp = (SldWorks)Marshal.GetActiveObject("SldWorks.Application"); } _swmodel = swApp.ActiveDoc; _swmodel.GetConfigurationByName(confname); var sMatDb = ""; var valout = _swmodel.CustomInfo2[confname, "RAL"]; var valout1 = _swmodel.CustomInfo2[confname, "Тип покрытия"]; var valout2 = _swmodel.CustomInfo2[confname, "Класс покрытия"]; //var valout3 = ""; //var matname = new MatName(); //if (CheckType == 0) //{ valout3 = _swmodel.CustomInfo2[confname, "Наименование"]; // matname.Name = valout3; } //if (CheckType == 1) //{ var swpart = (PartDoc)_swmodel; // matname.Name = swpart.GetMaterialPropertyName2(confname, out sMatDb); } //matname.ColorSQL = valout; //matname.CoatingType = valout1; //matname.CoatingClass = valout2; var swpart = (PartDoc)_swmodel; var matname = new MatName() { Name = swpart.GetMaterialPropertyName2(confname, out sMatDb), ColorSQL = valout, CoatingType = valout1, CoatingClass = valout2 }; customnamelist.Add(matname); } catch (Exception ex) { MessageBox.Show($"Message: {ex.Message}\r\nTargetSite: {ex.TargetSite}\r\nStackTrace: {ex.StackTrace}"); } return(customnamelist); }
// public List <MatName> GetCustomProperty(string confname, SldWorks swApp) { try { var customnamelist = new List <MatName>(); customnamelist.Clear(); if (swApp == null) { swApp = (SldWorks)Marshal.GetActiveObject("SldWorks.Application"); } _swmodel = swApp.ActiveDoc; _swmodel.GetConfigurationByName(confname); var swpart = (PartDoc)_swmodel; var sMatDb = ""; var valout = _swmodel.CustomInfo2[confname, "RAL"]; var valout1 = _swmodel.CustomInfo2[confname, "Тип покрытия"]; var valout2 = _swmodel.CustomInfo2[confname, "Класс покрытия"]; var matname = new MatName() { Name = swpart.GetMaterialPropertyName2(confname, out sMatDb), ColorSQL = valout, CoatingType = valout1, CoatingClass = valout2 }; customnamelist.Add(matname); return(customnamelist); } catch (Exception ex) { MessageBox.Show(ex.ToString()); throw; } }
private void buttonSearch_Click(object sender, EventArgs e) { CmatnametextBox.Clear(); WFilter wf = new WFilter(1, "MatName", true); wf.tableName = "T_MatInf"; //表名 wf.strSql = "select T_MatInf.MatID 物料编号,MatName 物料名称,Specifications 型号规格 ,Units 计量单位," + "Brand 品牌,ProductType 产品种类,ColorType 色彩,Speed 速度等级,Format 幅面,ynStopProduct 是否已停产," + "ConfigType 配置类型,purchaseprice 标准进货价 " + "from T_MatInf"; wf.s_items.Add("物料编号,MatID,C"); wf.s_items.Add("物料名称,MatName,C"); wf.s_items.Add("拼音编码,PinYinCode,C"); wf.s_items.Add("品牌,Brand,C"); wf.ShowDialog(); if (wf.DialogResult == DialogResult.OK) { //插入 List <string> sqls = new List <string>(); DBUtil dbUtil = new DBUtil(); string curpmatid = this.pMatId; foreach (string MatName in wf.Return_Items) { string curcmatid = dbUtil.Get_Single_val("T_MatInf", "MatID", "MatName", MatName.Trim()); if (curcmatid == "") { continue; } //插入前判断存在性和与与主物料的排斥性 string strSqlSel = "select * from T_Mat_Rela where ParentMatId='{0}' and ChildMatId='{1}'"; strSqlSel = string.Format(strSqlSel, curpmatid, curcmatid); bool isExit = dbUtil.yn_exist_data(strSqlSel); if (isExit == true || curpmatid == curcmatid.Trim()) { continue; } string strSql = "insert into T_Mat_Rela(ParentMatId,ChildMatId) values('{0}','{1}')"; strSql = string.Format(strSql, curpmatid, curcmatid); sqls.Add(strSql); } (new SqlDBConnect()).Exec_Tansaction(sqls); initdataGridview(); } }