Esempio n. 1
0
        /// <summary>
        /// Exports Material Info to a .txt file
        /// </summary>
        private void ExportMaterialInfo(Model.Material material, string path)
        {
            try
            {
                using (var writer = new StreamWriter(path))
                {
                    writer.WriteLine("# Textures");
                    foreach (var texture in material.Images)
                    {
                        writer.WriteLine("{0}:{1}", texture.Key, texture.Value);
                    }
                    writer.WriteLine("# Settings");

                    foreach (var setting in material.Settings)
                    {
                        writer.Write("{0}:", setting.Key);

                        var things = (float[])setting.Value;

                        foreach (var thing in things)
                        {
                            writer.Write("{0} ", thing);
                        }

                        writer.WriteLine();
                    }
                }
            }
            catch
            {
                return;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Exports Material Images
        /// </summary>
        private void ExportMaterialImages(Model.Material material, string folder)
        {
            var imageKeys = material.Images.Keys.ToArray();

            foreach (var key in imageKeys)
            {
                // Resolve, we try the streaming folder first, as they contain the highest quality images
                // vs the lowest ones loaded in memory
                foreach (var prefix in DirectoryPrefixes)
                {
                    var fullPath = prefix + material.Images[key];

                    foreach (var suffix in FileSuffixes)
                    {
                        if (ActivePackage.Entries.TryGetValue(MurMur3.Calculate(Encoding.Unicode.GetBytes(fullPath + suffix)), out var imageFile))
                        {
                            try
                            {
                                var imagePath = ExportImage(imageFile, Path.Combine(folder, "_images", Path.GetFileNameWithoutExtension(fullPath)));
                                Directory.CreateDirectory(Path.GetDirectoryName(imagePath));
                                material.Images[key] = Path.Combine("_images", Path.GetFileName(imagePath));
                                break;
                            }
                            catch
                            {
                                continue;
                            }
                        }
                    }
                }
            }
        }
        public MaterialCreateIfNotExist(Model.Material material, string tobeinsertedMaterialCategory2OrCategory3, string unitName, double unitPrice)
        {
            IsValidated = true;

            if (material.CategoryID0 == 0)
            {
                IsValidated    = false;
                ResultMessage += "Please Choose a Category;  " + Environment.NewLine;
            }
            if (material.CategoryID1 == 0)
            {
                IsValidated    = false;
                ResultMessage += "Please Choose a Sub-Category 1;  " + Environment.NewLine;
            }
            _unitID = GetUnitID(unitName);
            if (_unitID == 0)
            {
                IsValidated    = false;
                ResultMessage += "Can not find the Unit Name; " + Environment.NewLine;
            }
            if (!IsValidated)
            {
                return;
            }


            _tobeinsertedMaterialCategory2OrCategory3 = tobeinsertedMaterialCategory2OrCategory3;
            _myMaterial = material;
            _unitPrice  = unitPrice;
        }
Esempio n. 4
0
        private void Delete()
        {
            DialogResult result = FormUtility.MsgDelete();

            if (result == DialogResult.Yes)
            {
                int            i        = gridView1.GetSelectedRows().FirstOrDefault();
                Model.Material material = gridView1.GetRow(i) as Model.Material;
                if (material == null)
                {
                    return;
                }
                try
                {
                    using (IUnitOfWork uow = new UnitOfWork())
                    {
                        uow.MaterialRepository.Remove(material);
                        uow.MaterialRepository.RemoveFromProduct(material.MaterialId);
                        uow.Commit();
                    }
                    gridView1.DeleteRow(i);
                }
                catch
                {
                    lblNotify1.SetText(UI.removefailed, ToolBoxCS.LabelNotify.EnumStatus.Failed);
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Get a Material by id from the database
        /// </summary>
        public virtual Model.Material GetById(Int32 id)
        {
            DbDataReader reader = null;

            try
            {
                var helper = Database.GetDbHelper();

                reader = helper.ExecuteSPReader(_storedProcedure_GetById,
                                                helper.CreateInputParam("@Id", id));

                Model.Material result = null;

                if (reader.Read())
                {
                    result = CreateMaterial(reader);
                }

                return(result);
            }
            catch (Exception ex)
            {
                Trace.WriteError("{0}", Trace.GetMethodName(), CLASSNAME, ex, id);
                throw DbHelper.TranslateException(ex);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
Esempio n. 6
0
 public frmEditMaterial(Model.Material material)
 {
     InitializeComponent();
     m_Material      = material;
     lblNotify1.Text = "";
     FormUtility.FormatForm(this);
 }
Esempio n. 7
0
        /// <summary>
        /// Add a new Material to the database
        /// </summary>
        public virtual Int32 Add(Model.Material newMaterial)
        {
            try
            {
                Trace.WriteVerbose("({0})", Trace.GetMethodName(), CLASSNAME, newMaterial.ToString());
                var         helper  = Database.GetDbHelper();
                DbParameter IdParam = helper.CreateOutputParam("@Id", DbType.Int32);

                int recordsAffected = helper.ExecuteSPNonQuery(_storedProcedure_Add,
                                                               IdParam,
                                                               helper.CreateInputParam("@MaterialGroupId", newMaterial.MaterialGroupId),
                                                               helper.CreateInputParam("@Code", newMaterial.Code),
                                                               helper.CreateInputParam("@Description", newMaterial.Description));

                if (recordsAffected == 0)
                {
                    throw new DalNothingUpdatedException("Unable to add Material with Id={0}", newMaterial);
                }

                return((Int32)IdParam.Value);
            }
            catch (Exception ex)
            {
                Trace.WriteError("({0})", Trace.GetMethodName(), CLASSNAME, ex, newMaterial.ToString());
                throw DbHelper.TranslateException(ex);
            }
        }
Esempio n. 8
0
        public Model.Material Recupera_Material(string strCodMaterial)
        {
            DataTable dt = new DataTable();

            Model.Material obj = new Model.Material();

            dt = SqlHelper.ExecuteDataTable(strConnection, "Logistica.spp_sel_msto_Material", strCodMaterial);

            if (dt.Rows.Count == 0)
            {
                obj.CcodMaterial     = "";
                obj.VnomMaterial     = "";
                obj.CcodUnidadMedida = "";
                obj.Fstock           = 0;
            }
            else
            {
                obj.CcodMaterial     = Convert.ToString(dt.Rows[0][0]);
                obj.VnomMaterial     = Convert.ToString(dt.Rows[0][1]);
                obj.CcodUnidadMedida = Convert.ToString(dt.Rows[0][2]);
                obj.Fstock           = Convert.ToDouble(dt.Rows[0][3]);
            }

            return(obj);
        }
Esempio n. 9
0
 public frmEditMaterial(MaterialRequestDataBase materialrequest)
 {
     InitializeComponent();
     materialRequestDataBase = materialrequest;
     m_Material      = materialrequest.Model;
     lblNotify1.Text = "";
 }
Esempio n. 10
0
        private void cbbMaterialCode_EditValueChanged(object sender, EventArgs e)
        {
            Model.Material       mat    = (sender as LookUpEdit).GetSelectedDataRow() as Model.Material;
            ImportMaterialDetail detail = new ImportMaterialDetail();
            ImportMaterialDetail exists = lstDetail.Where(p => p.MaterialId == mat.MaterialId).FirstOrDefault();
            int i = gridView2.FocusedRowHandle;
            ImportMaterialDetail selectedrow = gridView2.GetRow(i) as ImportMaterialDetail;

            detail.Material   = mat;
            detail.MaterialId = mat.MaterialId;
            detail.Price      = mat.Price;
            detail.ImportId   = import.ImportId;
            detail.Quantity   = 1;
            if (selectedrow == null || (selectedrow.MaterialId == 0) || selectedrow.MaterialId == null)
            {
                gridView2.DeleteRow(i);
                if (exists == null)
                {
                    //gridutility.AddNewRow(detail);
                    lstDetail.Add(detail);
                }
                else
                {
                    exists.Quantity += 1;
                }
            }
            else
            {
                gridutility.UpdateRow(detail);
            }
            gridView2.RefreshData();
        }
Esempio n. 11
0
 /// <summary>
 /// Setup uniforms for specified surface<para/>
 /// Установка параметров шейдера для поверхности
 /// </summary>
 /// <param name="surf">Surface<para/>Поверхность</param>
 /// <param name="mat">Material<para/>Материал поверхности</param>
 public override void SetupSurface(Model.SubMesh.Surface surf, Model.Material mat, ModelFile.Geometry geom, Model.SubMesh subMesh)
 {
     GL.Uniform1(StaticShader.AppearValue, Fading ? FadingDelta : 1f);
     GL.Uniform3(StaticShader.AmbientColor, Renderer.SkyState.AmbientStatic);
     GL.Uniform3(StaticShader.DiffuseColor, Renderer.SkyState.DirectLight);
     GL.Uniform4(StaticShader.TintColor, new Color4(mat.Color[0], mat.Color[1], mat.Color[2], mat.Color[3]));
 }
Esempio n. 12
0
 public static string GetMaterialName(Model.Material material)
 {
     return(material.MaterialCategory1.CategoryName + " " +
            (material.CategoryID2 == 0 ? "" : material.MaterialCategory2.CategoryName + " ") +
            (material.CategoryID3 == 0 ? "" : material.MaterialCategory3.CategoryName + " ") +
            (material.CategoryID4 == 0 ? "" : material.MaterialCategory4.CategoryName));
 }
Esempio n. 13
0
        public static string GetMaterialPrice(Model.Material material)
        {
            var currentPrice = string.Format("{0:C2}", material.Price);
            var unitName     = material.MaterialPriceUnit.UnitName;

            return(currentPrice + "/" + unitName);
        }
Esempio n. 14
0
        /// <summary>
        /// Converts the given material file
        /// </summary>
        public static Dictionary <string, Model.Material> ConvertRE3(BinaryReader reader)
        {
            var results = new Dictionary <string, Model.Material>();

            {
                reader.BaseStream.Position = 0;
                var header    = reader.ReadStruct <MaterialHeaderRE7>();
                var materials = reader.ReadArray <MaterialEntryRE2>(header.MaterialCount);

                Console.WriteLine(Marshal.SizeOf <MaterialEntryRE2>());

                foreach (var material in materials)
                {
                    var result = new Model.Material(reader.ReadUTF16NullTerminatedString(material.NamePointer));

                    foreach (var texture in reader.ReadArray <MaterialTextureEntryRE3>(material.TexturesPointer, material.TextureCount))
                    {
                        result.Images[reader.ReadUTF16NullTerminatedString(texture.TypePointer)] = reader.ReadUTF16NullTerminatedString(texture.TextureNamePointer).ToLower();
                    }
                    //foreach (var setting in reader.ReadArray<MaterialSettingsInfoRE7>(material.SettingsInfoPointer, material.SettingsInfoCount))
                    //    result.Settings[reader.ReadUTF16NullTerminatedString(setting.NamePointer)] = reader.ReadArray<float>(material.SettingsBufferPointer + setting.DataOffset, setting.DataCount);

                    results[result.Name] = result;
                }
            }

            return(results);
        }
Esempio n. 15
0
 /// <summary>
 /// Update a Material.
 /// </summary>
 public void Update(Model.Material material)
 {
     //
     // todo: add other logic here.
     //
     accessor.Update(material);
 }
        /// <summary>
        /// Delete the given Material from the database
        /// </summary>
        public virtual void Delete(Model.Material delMaterial)
        {
            try
            {
                Trace.WriteInformation("({0})", Trace.GetMethodName(), CLASSNAME, delMaterial);

                //Begin Checks
                if (!Exists(delMaterial))
                {
                    throw new BusinessException(string.Format("There is no Material with this id. ({0})", delMaterial));
                }

                DataAccess.Materials materials = new DataAccess.Materials();
                materials.Delete(delMaterial);
            }
            catch (DalForeignKeyException ex_fk)
            {
                Trace.WriteError("({0})", Trace.GetMethodName(), CLASSNAME, ex_fk, delMaterial);
                throw new BusinessException(string.Format("The Material is still used by {0}", ex_fk.Table), ex_fk);
            }
            catch (Exception ex)
            {
                Trace.WriteError("({0})", Trace.GetMethodName(), CLASSNAME, ex, delMaterial);
                throw;
            }
        }
Esempio n. 17
0
        public bool ExistsExcept(Model.Material e)
        {
            Hashtable paras = new Hashtable();

            paras.Add("newId", e.Id);
            paras.Add("oldId", Get(e.MaterialId) == null?null:Get(e.MaterialId).Id);
            return(sqlmapper.QueryForObject <bool>("Material.existsexcept", paras));
        }
Esempio n. 18
0
 /// <summary>
 /// Insert a Material.
 /// </summary>
 public void Insert(Model.Material material)
 {
     //
     // todo:add other logic here
     //
     material.InsertTime = DateTime.Now;
     material.UpdateTime = DateTime.Now;
     accessor.Insert(material);
 }
Esempio n. 19
0
        public string GetMaterial(Model.Material material)
        {
            Util.Ftp.FtpFile ftpFile = new Util.Ftp.FtpFile();
            ftpFile.Title    = material.Name;
            ftpFile.FilePath = material.Path;
            string tempFilePath = Path.Combine(tempFileDir, material.Name);

            Util.Ftp.FtpHelper.DownLoad(ftpFile, tempFilePath);
            return(ftpFile.Title);
        }
Esempio n. 20
0
        public MaterialContextMenu()
        {
            InitializeComponent();
            isCopied = false;
            ContextItem ctxItem = new ContextItem();

            ctxItem.ShowDelete = true;
            Init(ctxItem);
            m_MaterialOrigin = null;
        }
Esempio n. 21
0
 private void AddOrUpdateRow(Model.Material material, CRUD flag)
 {
     if (flag == CRUD.Insert)
     {
         lstUpdate.Add(material);
     }
     else
     {
         gridView1.RefreshData();
     }
 }
Esempio n. 22
0
 private void AddOrUpdateRow(Model.Material material, CRUD flag)
 {
     if (flag == CRUD.Insert)
     {
         gridUtility.AddNewRow <Model.Material>(material);
     }
     else
     {
         gridUtility.UpdateRow <Model.Material>(material);
     }
 }
Esempio n. 23
0
 public int DeleteMaterial(Model.Material material)
 {
     if (new Rule.MaterialRule().TestDelete(material.MaterialID))
     {
         return(new DAL.Materialdal().DeleteMaterial(material.MaterialID.ToString()));
     }
     else
     {
         return(-5);
     }
 }
Esempio n. 24
0
 public int UpdateMaterial(Model.Material material)
 {
     if (new Rule.MaterialRule().TestUpdate(material.MaterialName, material.MaterialID))
     {
         return(new DAL.Materialdal().UpdateMaterial(material));
     }
     else
     {
         return(-5);
     }
 }
Esempio n. 25
0
 public int InsertMaterial(Model.Material material)
 {
     if (new Rule.MaterialRule().TestInsert(material.MaterialName))
     {
         return(new DAL.Materialdal().InsertMaterial(material));
     }
     else
     {
         return(-5);
     }
 }
 /// <summary>
 /// Equals function to compare class
 /// </summary>
 public virtual bool Exists(Model.Material material)
 {
     try
     {
         return(this.GetById(material.Id) != null);
     }
     catch (Exception ex)
     {
         Trace.WriteError("({0})", Trace.GetMethodName(), CLASSNAME, ex, material);
         throw;
     }
 }
Esempio n. 27
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            Model.Material material = gridUtility.GetSelectedItem <Model.Material>() as Model.Material;
            if (material == null)
            {
                return;
            }
            frmEditMaterial frmEdit = new frmEditMaterial(material);

            frmEdit.ShowDialog();
            LoadGrid();
        }
Esempio n. 28
0
        private void Create()
        {
            Model.Material          material = new Model.Material();
            MaterialRequestDataBase requeset = new MaterialRequestDataBase
            {
                IsEdit         = false,
                Model          = material,
                AddOrUpdateRow = AddOrUpdateRow
            };
            frmEditMaterial frmEdit = new frmEditMaterial(requeset);

            frmEdit.ShowDialog();
        }
Esempio n. 29
0
        private void getData(int id)
        {
            JavaDLL dll = new JavaDLL();

            Model.Material cate = dll.getMaterialList(id);
            if (cate != null)
            {
                txtTitle.Text    = cate.title;
                txtUrl.Text      = cate.url;
                txtPassword.Text = cate.psd;
                txtRemark.Text   = cate.remark;
            }
        }
        /// <summary>
        /// Check Datafield constraints
        /// </summary>
        protected virtual void CheckConstraints(Model.Material material)
        {
            //Range checks, etc checks go here
            if (material.Description == null)
            {
                throw new BusinessException(string.Format("Description may not be NULL. ({0})", material.Description));
            }

            if (material.Description.Length > 50)
            {
                throw new BusinessException(string.Format("Description may not be longer than 50 characters. ({0})", material.Description));
            }
        }