Ejemplo n.º 1
0
        private void button11_Click(object sender, EventArgs e)
        {
            if (txtRate.Text.Equals("") || cmbProductSubCategory.Text.Equals("") || txtProductCode.Text.Equals("") | (cmbDepartment.SelectedValue == null) | (cmbSections.SelectedValue == null))
            {
                MessageBox.Show(this, "Please Fill all Fields", "Blank Fields", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            else
            {
                try
                {
                    objBasicProduct.BasicProductAVGCost     = Convert.ToDecimal(txtRate.Text);
                    objBasicProduct.BasicProductCategory    = objProductCategoryDL.Get(cmbCategory.SelectedValue.ToString());
                    objBasicProduct.BasicProductCode        = txtProductCode.Text;
                    objBasicProduct.BasicProductDescription = txtProductDescription.Text;
                    objBasicProduct.BasicProductForm        = objFormDL.Get(Convert.ToInt64(cmbForm.SelectedValue));
                    // objBasicProduct.BasicProductFormula = null;
                    objBasicProduct.BasicProductName        = "";
                    objBasicProduct.BasicProductStatus      = !chkDisable.Checked;
                    objBasicProduct.BasicProductSubCategory = objProductSubCategory_DL.Get(cmbProductSubCategory.SelectedValue.ToString());
                    objBasicProduct.BasicProductType        = cmbProductType.SelectedItem.ToString();
                    objBasicProduct.BasicProductUnit        = objUnitDL.Get(Convert.ToInt64(cmbUnit.SelectedValue));
                    objBasicProduct.STDBatchSize            = Convert.ToDecimal(txtSTDBatchSize.Text);



                    int x;

                    x = objbasicProductDL.Add(objBasicProduct, Convert.ToInt32(cmbDepartment.SelectedValue), Convert.ToInt32(cmbSections.SelectedValue));

                    if (x > 0)
                    {
                        MessageBox.Show(this, "Succesfully Added to Database", "Succesfull", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.ClearBasicProduct();
                    }

                    BasicProductBinidinSourse.DataSource = objbasicProductDL.GetDataView_By_Category(cmbCategory.SelectedValue.ToString());
                    gvBasicProduct.DataSource            = BasicProductBinidinSourse;
                }
                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);
                }
                finally
                {
                }
            }
        }
Ejemplo n.º 2
0
        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);
                }
            }
        }
Ejemplo n.º 3
0
        //-------------- Events ----------------------------------------


        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";


                        int x = 0;
                        if (this.MaterialSelect)
                        {
                            //x = objMaterialDL.Add(objMaterial, objSelectedMaterial.MaterialCode,SubcatL1,SubCatL2);
                            MaterialClear();

                            bindMaterials.DataSource = objMaterialDL.GetDataView(cmbCatergory.SelectedValue.ToString());

                            if (x > 0)
                            {
                                MessageBox.Show(this, "Succesfully Updated the Database", "Succesfull", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                int counter = 0;
                                foreach (DataGridViewRow var in gvMaterialList.Rows)
                                {
                                    if (var.Cells["ColMaterialCode"].Value.Equals(objMaterial.MaterialCode))
                                    {
                                        gvMaterialList.CurrentCell = gvMaterialList[1, counter];
                                        gvMaterialList.FirstDisplayedScrollingRowIndex = counter;

                                        break;
                                    }
                                    counter++;
                                }
                            }
                        }
                        else
                        {
                            // x = objMaterialDL.Add(objMaterial,"",SubcatL1,SubCatL2);
                            if (x > 0)
                            {
                                MaterialClear();
                                bindMaterials.DataSource = objMaterialDL.GetDataView(cmbCatergory.SelectedValue.ToString());
                                MessageBox.Show(this, "Succesfully Added to Database", "Succesfull", MessageBoxButtons.OK, MessageBoxIcon.Information);


                                int counter = 0;
                                foreach (DataGridViewRow var in gvMaterialList.Rows)
                                {
                                    if (var.Cells["ColMaterialCode"].Value.Equals(objMaterial.MaterialCode))
                                    {
                                        gvMaterialList.CurrentCell = gvMaterialList[1, counter];
                                        gvMaterialList.FirstDisplayedScrollingRowIndex = counter;

                                        break;
                                    }
                                    counter++;
                                }
                            }
                            else if (x == -1)
                            {
                                MessageBox.Show(this, "Material Code already in the Database,Please enter another Material Code", "Problem with Material Code", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                        this.MaterialSelect = false;
                    }
                    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);
                    }
                }
            }
            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.IsExport            = cbMaterialImport.Checked;
                        objMaterial.IsLocal             = cbMaterialLocal.Checked;
                        objMaterial.IsSeasanal          = cbMaterialSeasonal.Checked;
                        objMaterial.MatBasicMaterial    = objMaterial.MaterialCode;
                        objMaterial.MatBasicQty         = 0;
                        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 (cbMaterialSeasonal.Checked)
                        {
                            objMaterial.MatSeasonFrom = cmbFromMonth.SelectedItem.ToString();
                            objMaterial.MatSeasonTo   = cmbToMonth.SelectedItem.ToString();
                        }
                        else
                        {
                            objMaterial.MatSeasonFrom = "N/A";
                            objMaterial.MatSeasonTo   = "N/A";
                        }


                        objMaterial.MatUnit = objUnitDL.Get(Convert.ToInt64(cmbMaterialUnit.SelectedValue));
                        int x = 0;

                        if (this.MaterialSelect)
                        {
                            // x = objMaterialDL.Add(objMaterial, objSelectedMaterial.MaterialCode,SubcatL1,SubCatL2);
                            MaterialClear();
                            bindMaterials.DataSource = objMaterialDL.GetDataView(cmbCatergory.SelectedValue.ToString());
                            if (x > 0)
                            {
                                MessageBox.Show(this, "Succesfully Updated the Database", "Succesfull", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                int counter = 0;
                                foreach (DataGridViewRow var in gvMaterialList.Rows)
                                {
                                    if (var.Cells["ColMaterialCode"].Value.Equals(objMaterial.MaterialCode))
                                    {
                                        gvMaterialList.CurrentCell = gvMaterialList[1, counter];
                                        gvMaterialList.FirstDisplayedScrollingRowIndex = counter;

                                        break;
                                    }
                                    counter++;
                                }
                            }
                        }
                        else
                        {
                            //  x = objMaterialDL.Add(objMaterial,"",SubcatL1,SubCatL2);


                            if (x > 0)
                            {
                                MaterialClear();
                                bindMaterials.DataSource = objMaterialDL.GetDataView(cmbCatergory.SelectedValue.ToString());
                                MessageBox.Show(this, "Succesfully Added to Database", "Succesfull", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                int counter = 0;
                                foreach (DataGridViewRow var in gvMaterialList.Rows)
                                {
                                    if (var.Cells["ColMaterialCode"].Value.Equals(objMaterial.MaterialCode))
                                    {
                                        gvMaterialList.CurrentCell = gvMaterialList[1, counter];
                                        gvMaterialList.FirstDisplayedScrollingRowIndex = counter;

                                        break;
                                    }
                                    counter++;
                                }
                            }
                            else if (x == -1)
                            {
                                MessageBox.Show(this, "Material Code already in the Database,Please enter another Material Code", "Problem with Material Code", 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);
                    }
                }
            }
        }