예제 #1
0
        // GetMaterialsNameList
        public List <string> GetMaterialsNameList(SldWorks swApp)
        {
            try
            {
                var listMatName = new List <string>();

                var matDll = new SetMaterials();

                var confarray2 = matDll.GetConfigurationNames(swApp);

                foreach (var confname in confarray2)
                {
                    var matname = matDll.GetCustomProperty(confname, swApp);

                    foreach (var customProperty in matname)
                    {
                        listMatName.Add(customProperty.Name);
                    }
                }

                //var matDll = new SetMaterials();

                //var confarray2 = matDll.GetConfigurationNames(swApp);

                //return (from confname in confarray2 from customProperty in matDll.GetCustomProperty(confname, swApp) select customProperty.Name).ToList();

                return(listMatName);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                throw;
            }
        }
예제 #2
0
        // Применяем свойства из SQL
        public void AddCustomProperty(string configName, string matName, SldWorks swApp)
        {
            try
            {
                var materialDataTable = MaterialsTable();

                foreach (DataRow dataRow in materialDataTable.Rows)
                {
                    if (dataRow["MaterialsName"].ToString() == matName)
                    {
                        var Thickness = dataRow["Thickness"].ToString();

                        var setThickness = new SetMaterials();

                        if (Convert.ToBoolean(Thickness))
                        {
                            setThickness.AddPropThickness(configName, true);
                        }
                        else
                        {
                            setThickness.AddPropThickness(configName, false);
                        }

                        var lvlId = dataRow["LevelID"].ToString();
                        //string MaterialName = datarow[MatName].ToString();
                        //string matName = dataRow["MaterialsName"].ToString();
                        var materialsNameEng = dataRow["MaterialsNameEng"].ToString();

                        var codeErp = dataRow["ERP"].ToString();
                        //string Plotnost = dataRow["destiny"].ToString();
                        var swProp = dataRow["swProperty"].ToString();
                        //string Description = dataRow["Descrip"].ToString();
                        var codeMateriala = dataRow["CodeMaterial"].ToString();
                        var descriptCode  = dataRow["DescriptionCode"].ToString();

                        var setCustomProperty = new SetMaterials();
                        setCustomProperty.CustomProperty(lvlId, configName, swProp, materialsNameEng, codeErp, codeMateriala, descriptCode, swApp);
                    }
                }
            }
            catch (Exception ex)
            {
                Error = ex.Message;
            }
        }
예제 #3
0
        // Берем Ral, Rus, ERPCode для применение в DataGrid
        //public class RalSQL
        //{
        //    public string Ral { get; set; }
        //    public string Rus { get; set; }
        //    public string ERPCode { get; set; }
            
        //}

        //public List<RalSQL> SetRalSql(string ConfigName, bool color)
        //{
        //    var RalSql = new List<RalSQL>();
        //    try
        //    {
        //        SqlConnection sqlconn = new SqlConnection(Conn);
        //        SqlCommand sqlcmd = new SqlCommand();
        //        SqlDataAdapter sqlda = new SqlDataAdapter();
        //        sqlconn.Open();
        //        DataSet ds = new DataSet();
        //        DataTable dt = new DataTable();
        //        ds.Tables.Add(dt);
        //        sqlcmd.CommandText = "SELECT ral, Rus, Hex, ERPCode FROM RAL where Applicability =" + 1;

        //        sqlcmd.Connection = sqlconn;
        //        sqlda.SelectCommand = sqlcmd;
        //        sqlda.Fill(dt);
        //        var SetMat = new SetMaterials();
        //        foreach (DataRow datarow in dt.Rows)
        //        {

        //            var ralsql = new RalSQL
        //            {
        //                Ral = datarow["Ral"].ToString(),
        //                Rus = datarow["Rus"].ToString(),
        //                ERPCode = datarow["ERPCode"].ToString()

        //            };

        //            RalSql.Add(ralsql);
        //        }

                
        //        sqlconn.Close();
        //    }
        //    catch (Exception ex)
        //    {
        //        MessageBox.Show(ex.ToString());
        //        throw;
        //    }

      
        //    return RalSql;
        //}

        internal void SetRalSql(string configName, string hex, string coatingtype, string coatingclass, bool color, SldWorks swApp)
        {
            var raldatatable = RalTable();
            SetMaterials setMat = new SetMaterials(swApp);
            foreach (DataRow dataRow in raldatatable.Rows)
            {
                if (dataRow["hex"].ToString() == hex)
                {
                    var ral = dataRow["Ral"].ToString();
                    
                    var rus = dataRow["Rus"].ToString();
                    var erpCode = dataRow["ERPCode"].ToString();

                    setMat.DeleteOrAddPropertyColor(configName, ral, rus, erpCode, coatingtype, coatingclass, color, swApp);
                   
                }
            } 
        }
예제 #4
0
        // Применяем свойства из SQL
        public void AddCustomProperty(string configName, int materialID, SldWorks swApp)
        {
            int lvlId;
            string materialsNameEng;
            string codeErp;
            string swProp;
            string codeMateriala;
            string descriptCode;

            DataTable materialDataTable = MaterialsTable();
            SetMaterials setMat = new SetMaterials(swApp);
            foreach (DataRow dataRow in materialDataTable.Rows)
            {
                if ((int)dataRow["LevelID"] == materialID)
                {
                    string Thickness = dataRow["Thickness"].ToString();



                    if (Convert.ToBoolean(Thickness))
                    {
                        setMat.Thickness(configName, true);
                    }
                    else
                    {
                        setMat.Thickness(configName, false);
                    }

                    lvlId = (int)dataRow["LevelID"];
                    materialsNameEng = dataRow["MaterialsNameEng"].ToString();
                    codeErp = dataRow["ERP"].ToString();
                    swProp = dataRow["swProperty"].ToString();
                    codeMateriala = dataRow["CodeMaterial"].ToString();
                    descriptCode = dataRow["MaterialsName"].ToString();

                    setMat.CustomProperty(lvlId, configName, swProp, materialsNameEng, codeErp, codeMateriala, descriptCode, swApp);
                }
            }
            setMat.ApplyMaterial("", configName, materialID, swApp);
        }