private void btnMaterialSave_Click(object sender, EventArgs e) { if (this.IntermediateMaterialSelect) { if (txtAcgUnitCost.Text.Equals("") || txtMaterialBasicPartialSize.Text.Equals("") || txtMaterialCode.Text.Equals("") || txtMaterialQtyPerUnit.Text.Equals("") || txtmaterialName.Text.Equals("") ) { MessageBox.Show(this, "Please Fill all Fields", "Blank Fields", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { try { objMaterial.MatBasicMaterial = cmbMaterialBasicMaterial.SelectedValue.ToString(); objMaterial.MatBasicQty = Convert.ToDecimal(txtMaterialQtyPerUnit.Text); objMaterial.MatCost = Convert.ToDecimal(txtAcgUnitCost.Text); objMaterial.MateialType = objMaterialTypeDL.Get(cmbMaterialType.SelectedValue.ToString()); objMaterial.MaterialMainType = MainType; objMaterial.MaterialCode = txtMaterialCode.Text.Replace(" ", ""); objMaterial.MaterialDescription = txtmaterialName.Text; objMaterial.MaterialStatus = Convert.ToInt32(Material.Status.Enable); objMaterial.MatForm = objFormDL.Get(Convert.ToInt64(cmbMaterialForm.SelectedValue)); objMaterial.MatParticleSize = (txtMaterialBasicPartialSize.Text); objMaterial.MatUnit = objUnitDL.Get(Convert.ToInt64(cmbMaterialUnit.SelectedValue)); objMaterial.MatSeasonFrom = "N/A"; objMaterial.MatSeasonTo = "N/A"; if (rdbDry.Checked == true) { objMaterial.MaterialType = "Dry"; } else if (rdbGreen.Checked == true) { objMaterial.MaterialType = "Green"; } else { objMaterial.MaterialType = "Normal"; } if (rdbRaw.Checked == true) { objMaterial.MaterialCategory = "Raw"; } else if (rdbPacking.Checked == true) { objMaterial.MaterialCategory = "Packing"; } else { objMaterial.MaterialCategory = "Lab"; } int x = 0; x = objMaterialDL.Add(objMaterial); MaterialClear(); if (x > 0) { MessageBox.Show(this, "Succesfully Updated the Database", "Succesfull", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadMaterials(Category); } } catch (FormatException) { MessageBox.Show(this, "Please enter valid data", "Input Data Invalid", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } LoadMaterials(Category); } } else { if (txtAcgUnitCost.Text.Equals("") || txtmaterialName.Text.Equals("") || txtMaterialCode.Text.Equals("")) { MessageBox.Show(this, "Please fill All Fields", "Blank Fields", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { try { objMaterial.MaterialCode = txtMaterialCode.Text; objMaterial.IsExport = cbMaterialImport.Checked; objMaterial.IsLocal = cbMaterialLocal.Checked; objMaterial.IsSeasanal = cbMaterialSeasonal.Checked; objMaterial.MatBasicQty = Convert.ToDecimal(txtMaterialQtyPerUnit.Text); objMaterial.MatBasicMaterial = objMaterial.MaterialCode; objMaterial.MatCost = Convert.ToDecimal(txtAcgUnitCost.Text); objMaterial.MateialType = objMaterialTypeDL.Get(cmbMaterialType.SelectedValue.ToString()); objMaterial.MaterialCategory = Category; objMaterial.MaterialMainType = MainType; objMaterial.MaterialCode = txtMaterialCode.Text; objMaterial.MaterialDescription = txtmaterialName.Text; objMaterial.MaterialStatus = Convert.ToInt32(Material.Status.Enable); objMaterial.MatForm = objFormDL.Get(Convert.ToInt64(cmbMaterialForm.SelectedValue)); objMaterial.MatParticleSize = "N/A"; if (rdbDry.Checked == true) { objMaterial.MaterialType = "Dry"; } else if (rdbGreen.Checked == true) { objMaterial.MaterialType = "Green"; } else { objMaterial.MaterialType = "Normal"; } if (cbMaterialSeasonal.Checked) { objMaterial.MatSeasonFrom = cmbFromMonth.SelectedItem.ToString(); objMaterial.MatSeasonTo = cmbToMonth.SelectedItem.ToString(); } else { objMaterial.MatSeasonFrom = "N/A"; objMaterial.MatSeasonTo = "N/A"; } if (rdbRaw.Checked == true) { objMaterial.MaterialCategory = "Raw"; } else if (rdbPacking.Checked == true) { objMaterial.MaterialCategory = "Packing"; } else { objMaterial.MaterialCategory = "Lab"; } objMaterial.MatUnit = objUnitDL.Get(Convert.ToInt64(cmbMaterialUnit.SelectedValue)); int x = 0; x = objMaterialDL.Add(objMaterial); MaterialClear(); if (x > 0) { MessageBox.Show(this, "Succesfully Updated the Database", "Succesfull", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (FormatException) { MessageBox.Show(this, "Please enter valid data", "Input Data Invalid", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } LoadMaterials(Category); } } }