/// <summary> /// Update the current effect. This method will change. /// </summary> /// <param name="effect"></param> /// <param name="material"></param> private void UpdateEffect(BasicEffect effect, BasicMaterial material) { effect.Alpha = material.AlphaColor; effect.AmbientLightColor = material.AmbientColor * material.AmbientIntensity; effect.DiffuseColor = material.DiffuseColor * material.DiffuseIntensity; effect.EmissiveColor = material.EmissiveColor * material.EmissiveIntensity; effect.FogColor = material.FogColor; effect.FogEnabled = material.EnableFog; effect.FogStart = material.FogStart; effect.FogEnd = material.FogEnd; effect.LightingEnabled = true; if (material.EnableDefaultLighting) { effect.EnableDefaultLighting(); } effect.PreferPerPixelLighting = material.EnabledPerPixelLighting; effect.SpecularColor = material.SpecularColor * material.SpecularIntensity; effect.VertexColorEnabled = material.EnableVertexColor; SceneLight light = (SceneLight)material.Light; if (light != null) { StockMaterial.UpdateLighting(effect, light); effect.AmbientLightColor *= light.AmbientColor * light.AmbientIntensity; } }
public int updateMaterial(StockMaterial Mat) { dbCon.openCon(); cmd = new SqlCommand("update Stock_Materials set Material_Type = '" + Mat.MaterialType + "', Size = '" + Mat.Size + "', Color = '" + Mat.Color + "', Quantity = '" + Mat.Quantity + "', Descriptions = '" + Mat.Description + "' where Mat_id = '" + Mat.MatId + "'", dbCon.con); int status = cmd.ExecuteNonQuery(); dbCon.closeCon(); return(status); }
public int createMaterial(StockMaterial Mat) { dbCon.openCon(); String Status = "Not Damaged"; cmd = new SqlCommand("insert into Stock_Materials (Mat_id,Material_Type,Size,Color,Quantity,Descriptions,Damage_Status) values('" + Mat.MatId + "','" + Mat.MaterialType + "','" + Mat.Size + "','" + Mat.Color + "','" + Mat.Quantity + "','" + Mat.Description + "','" + Status + "')", dbCon.con); int status = cmd.ExecuteNonQuery(); dbCon.closeCon(); return(status); }
private void btn_M_Update_Click(object sender, EventArgs e) { try { if (cmb_Mtype.SelectedIndex == -1) { MessageBox.Show("You must select a Material Type", "Error"); } else if (cmb_MSize.SelectedIndex == -1) { MessageBox.Show("You must select a Size", "Error"); } else if (cmb_Mcolor.SelectedIndex == -1) { MessageBox.Show("You must select a Color", "Error"); } else if (string.IsNullOrEmpty(txt_Mqty.Text) || !Regex.Match(txt_Mqty.Text, "^[0-9]*$").Success) { MessageBox.Show("Invalid, Please enter price correctly", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (Convert.ToInt32(txt_Mqty.Text) <= 0) { MetroFramework.MetroMessageBox.Show(this, "Quantity cannot be minus or zero!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (!chk_ResMet.Checked) { StockMaterial SM = new StockMaterial(); SM.MatId = txt_MID.Text; SM.MaterialType = cmb_Mtype.Text; SM.Size = cmb_MSize.Text; SM.Color = cmb_Mcolor.Text; SM.Quantity = txt_Mqty.Text; SM.Description = txt_Area_M_Des.Text; StockDBaccess SD = new StockDBaccess(); int Status = SD.updateMaterial(SM); if (Status == 1) { MetroMessageBox.Show(this, "\n\nsuccesfully Updated", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MetroMessageBox.Show(this, "\n\nUpdate Fail", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error); } grid_met.DataSource = SD.getAllMaterial(); txt_MID.Text = SD.GetMaterialId(); cmb_ftype.Text = null; cmb_MSize.Text = null; cmb_Mcolor.Text = null; cmb_Mtype.Text = null; txt_Mqty.Text = ""; txt_Area_M_Des.Text = ""; grid_met.ClearSelection(); } } } catch (SqlException) { MetroMessageBox.Show(this, "\n\nConnecton Failed", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (FormatException) { MetroMessageBox.Show(this, "\n\nInvalid Format", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (OutOfMemoryException) { MetroMessageBox.Show(this, "\n\nInsuffisent memory", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception) { MetroMessageBox.Show(this, "\n\nERROR", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error); } }