Beispiel #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
                {
                }
            }
        }
Beispiel #2
0
        private void gvPackingType_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                PackingType_DL objPackingTypeDL = new PackingType_DL(ConnectionStringClass.GetConnection());
                Form_DL        objFormDL        = new Form_DL(ConnectionStringClass.GetConnection());
                Unit_DL        objUnitDL        = new Unit_DL(ConnectionStringClass.GetConnection());
                try
                {
                    txtPackingID.Text = Convert.ToString(gvPackingType.CurrentRow.Cells["ColPackingID"].Value);

                    objSelectedPackingType.Type         = Convert.ToString(gvPackingType.Rows[e.RowIndex].Cells["ColType"].Value);
                    objSelectedPackingType.PackingID    = Convert.ToInt64(gvPackingType.Rows[e.RowIndex].Cells["ColPackingID"].Value);
                    objSelectedPackingType.PackingQty   = Convert.ToDecimal(gvPackingType.Rows[e.RowIndex].Cells["ColPackingQty"].Value);
                    objSelectedPackingType.PackingTitle = gvPackingType.Rows[e.RowIndex].Cells["ColPackingTitle"].Value.ToString();
                    objSelectedPackingType.PackingUnit  = objUnitDL.Get(Convert.ToInt64(gvPackingType.Rows[e.RowIndex].Cells["colPackingUnitID"].Value));

                    txtPackingTypeName.Text = objSelectedPackingType.PackingTitle;
                    txtPackingTypeSize.Text = objSelectedPackingType.PackingQty.ToString();
                    cmbUnit.SelectedValue   = objSelectedPackingType.PackingUnit.UnitID.ToString();

                    this.PackingTypeSelect = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #3
0
        //----- Form Load Event ----------------------------------------------

        //----- Packing Type Events ----------------------------------------

        private void btnPackinTypeSave_Click(object sender, EventArgs e)
        {
            if (txtPackingTypeName.Text.Equals("") ||
                txtPackingTypeSize.Text.Equals(""))
            {
                MessageBox.Show(this, "Please Fill all Fields", "Blank Fields", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            else
            {
                try
                {
                    objSelectedPackingType.PackingQty   = Convert.ToDecimal(txtPackingTypeSize.Text);
                    objSelectedPackingType.PackingTitle = txtPackingTypeName.Text;
                    objSelectedPackingType.PackingUnit  = objUnitDL.Get(Convert.ToInt64(cmbUnit.SelectedValue));
                    objSelectedPackingType.PackingID    = Convert.ToInt64(gvPackingType.CurrentRow.Cells["ColPackingID"].Value);

                    if (rdbTertiary.Checked == true)
                    {
                        objSelectedPackingType.Type = "Tertiary";
                    }
                    else if (rdbSecondary.Checked == true)
                    {
                        objSelectedPackingType.Type = "Secondary";
                    }
                    else
                    {
                        objSelectedPackingType.Type = "Primary";
                    }
                    int x;

                    x = objPackingTypeDL.Add(objSelectedPackingType);

                    if (x > 0)
                    {
                        Load_Data();
                        MessageBox.Show(this, "Succesfully Saved", "Succesfull", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }


                    this.PackingTypeSelect = 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);
                }
                finally
                {
                }
            }
        }
Beispiel #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtBranch.Text.Equals("") ||
                txtCapacity.Text.Equals("") ||
                txtMachienDescription.Text.Equals("") ||
                txtMachineCode.Text.Equals("") ||
                txtMachineCostPerHour.Text.Equals("") ||
                txtMachineName.Text.Equals("") || txtWastagePercentage.Text.Equals(""))
            {
                errorProvider1.SetError(txtMachineCode, "Required Field");
                errorProvider1.SetError(txtCapacity, "Required Field");
                errorProvider1.SetError(txtMachienDescription, "Required Field");
                errorProvider1.SetError(txtMachineCostPerHour, "Required Field");
                errorProvider1.SetError(txtMachineName, "Required Field");
                errorProvider1.SetError(txtWastagePercentage, "Required Field");
                errorProvider1.SetError(txtBranch, "Required Field");

                MessageBox.Show(this, "Please Fill all Fields", "Blank Fields", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            else
            {
                errorProvider1.Clear();

                try
                {
                    objMachine.MachineBranch          = txtBranch.Text;
                    objMachine.MachineCapacity        = Convert.ToDecimal(txtCapacity.Text);
                    objMachine.MachineCapacityUnit    = objUnitDL.Get(Convert.ToInt64(cmbUnit.SelectedValue));
                    objMachine.MachineCode            = txtMachineCode.Text;
                    objMachine.MachineDescription     = txtMachienDescription.Text;
                    objMachine.MachineHourCost        = Convert.ToDecimal(txtMachineCostPerHour.Text);
                    objMachine.MachineName            = txtMachineName.Text;
                    objMachine.MachinePropertyTag     = txtPropertyTag.Text;
                    objMachine.MachinePurchaseDate    = dtPurchaseDate.Value;
                    objMachine.MachineSupplier        = "No";
                    objMachine.MachineTransferDetails = txtMachineTransferDetails.Text;
                    objMachine.MachineType            = objMachineTypeDL.Get(Convert.ToInt64(cmbMachineType.SelectedValue));
                    objMachine.MachineValue           = Convert.ToDecimal(txtMachineValue.Text);
                    objMachine.MachineWastage         = Convert.ToDecimal(txtWastagePercentage.Text);
                    int x;


                    x = objMachineDL.Add(objMachine);
                    gvMachine.DataSource = objMachineDL.GetDataView();

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

                        this.Clear();
                    }
                }
                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
                {
                }
            }
        }
Beispiel #5
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);
                }
            }
        }
Beispiel #6
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);
                    }
                }
            }
        }