Exemplo n.º 1
0
        private void refreshitems()
        {
            DataTable dtsup = SupplierDB.GetData();

            int nindex = Convert.ToInt32(bindingNavigatorSup.PositionItem.Text) - 1;

            txtSupId.Text   = dtsup.Rows[nindex]["SupplierId"].ToString();
            txtSupName.Text = dtsup.Rows[nindex]["SupName"].ToString();


            dgvSups.DataSource = SupplierDB.GetData();


            if (dgvSups.DataSource != null)
            {
                for (int i = 0; i < dgvSups.Rows.Count; i++)
                {
                    dgvSups.Rows[i].Selected = false;
                    dgvSups.Rows[i].DefaultCellStyle.BackColor = Color.White;
                }
                if (nindex < dgvSups.Rows.Count)
                {
                    dgvSups.Rows[nindex].Selected = true;
                    dgvSups.Rows[nindex].DefaultCellStyle.BackColor = Color.LightYellow;
                }
            }
        }
Exemplo n.º 2
0
        private void SupplierFrm_Load(object sender, EventArgs e)
        {
            BindingSource supbindsource = new BindingSource();

            supbindsource.DataSource          = SupplierDB.GetData();
            bindingNavigatorSup.BindingSource = supbindsource;
            refreshitems();
        }
Exemplo n.º 3
0
        private void BindingNavigatorAddNewItem_Click(object sender, EventArgs e)
        {
            BindingSource supbindsource = new BindingSource();

            supbindsource.DataSource          = SupplierDB.GetData();
            bindingNavigatorSup.BindingSource = supbindsource;

            txtSupId.Text   = "-1";
            txtSupName.Text = "";
        }
Exemplo n.º 4
0
        private void BindingNavigatorDeleteItem_Click(object sender, EventArgs e)
        {
            if (Validation())
            {
                if (txtSupId.Text == "-1" || txtSupId.Text == "")
                {
                    CustMesg msgfrm = new CustMesg();
                    msgfrm.Showmsg("Not a valid Supplier!");
                    msgfrm.Show();
                    refreshitems();
                    BindingSource supbindsource = new BindingSource();
                    supbindsource.DataSource          = SupplierDB.GetData();
                    bindingNavigatorSup.BindingSource = supbindsource;
                    //MessageBox.Show("Not a valid Supplier!");
                }
                else
                {
                    int       supId = Convert.ToInt32(txtSupId.Text);
                    Suppliers sup   = new Suppliers();
                    sup.nSupId     = supId;
                    sup.strSupName = txtSupName.Text;
                    if (!Prod_SuppliersDB.CheckSupInusebySupId(supId) && !SupplierContactsDB.CheckSupplierInuse(supId))
                    {
                        //if the supplier information is not in use in Prod_supplier table
                        SupplierDB.DeleteSupplier(sup);
                        refreshitems();
                    }
                    else
                    {
                        //if the supplier info is using in Prod_supplier table
                        CustMesg custMesg = new CustMesg();
                        custMesg.Showmsg("The Supplier is in use in Product_Supplier table,\n Please delete record in Product_Supplier table first!");
                        custMesg.Show();

                        refreshitems();
                        BindingSource supbindsource = new BindingSource();
                        supbindsource.DataSource          = SupplierDB.GetData();
                        bindingNavigatorSup.BindingSource = supbindsource;
                    }
                }
            }
            else
            {
                refreshitems();
                BindingSource supbindsource = new BindingSource();
                supbindsource.DataSource          = SupplierDB.GetData();
                bindingNavigatorSup.BindingSource = supbindsource;
            }
        }
Exemplo n.º 5
0
        private void refreshitems()
        {
            DataTable dtps = Prod_SuppliersDB.GetAllDatabyName();

            //bindingNavigatorPS.PositionItem.Text = dtps.Rows.Count.ToString();
            int nindex = Convert.ToInt32(bindingNavigatorPS.PositionItem.Text) - 1;

            if (nindex < dtps.Rows.Count)
            {
                txtProdSupID.Text = dtps.Rows[nindex]["ProductSupplierId"].ToString();

                cbProducts.DisplayMember  = "ProdName";
                cbProducts.ValueMember    = "ProductId";
                cbProducts.DataSource     = ProductDB.GetData();
                cbSuppliers.DisplayMember = "SupName";
                cbSuppliers.ValueMember   = "SupplierId";
                cbSuppliers.DataSource    = SupplierDB.GetData();

                cbProducts.Text  = dtps.Rows[nindex]["ProdName"].ToString();
                cbSuppliers.Text = dtps.Rows[nindex]["SupName"].ToString();
            }
            //if (dgvProdSup.DataSource==null)
            {
                dgvProdSup.DataSource = Prod_SuppliersDB.GetAllDatabyName();
            }
            if (dgvProdSup.DataSource != null)
            {
                for (int i = 0; i < dgvProdSup.Rows.Count; i++)
                {
                    dgvProdSup.Rows[i].Selected = false;
                    dgvProdSup.Rows[i].DefaultCellStyle.BackColor = Color.White;
                }
                if (nindex < dgvProdSup.Rows.Count)
                {
                    dgvProdSup.Rows[nindex].Selected = true;
                    dgvProdSup.Rows[nindex].DefaultCellStyle.BackColor = Color.LightYellow;
                }
            }
        }
Exemplo n.º 6
0
        private void ToolStripBtnSave_Click(object sender, EventArgs e)
        {
            if (Validation())
            {
                if (txtSupId.Text != "")
                {
                    int       supId = Convert.ToInt32(txtSupId.Text);
                    Suppliers sup   = new Suppliers();
                    sup.nSupId     = supId;
                    sup.strSupName = txtSupName.Text;
                    if (txtSupId.Text == "-1")
                    {
                        //insert new
                        if (SupplierDB.CheckSuppliersExistbyName(txtSupName.Text))
                        {
                            CustMesg msgfrm = new CustMesg();
                            msgfrm.Showmsg("Supplier exist already!");
                            msgfrm.Show();
                            //MessageBox.Show("Supplier exist already!");
                        }
                        else
                        {
                            SupplierDB.AddSupplier(sup);
                        }
                    }
                    else
                    {
                        //update

                        SupplierDB.UpdateSupplier(sup, sup);
                    }
                    refreshitems();

                    BindingSource supbindsource = new BindingSource();
                    supbindsource.DataSource          = SupplierDB.GetData();
                    bindingNavigatorSup.BindingSource = supbindsource;
                }
            }
        }