예제 #1
0
        private void purchaseStoredataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }
            try
            {
                if (e.ColumnIndex == 8) //when purchase
                {
                    PurchaseForm aForm = new PurchaseForm();
                    aForm.CategoryId         = Convert.ToInt32("0" + purchaseStoredataGridView.Rows[e.RowIndex].Cells[1].Value);
                    aForm.ItemId             = Convert.ToInt32("0" + purchaseStoredataGridView.Rows[e.RowIndex].Cells[0].Value);
                    aForm.itemnamelabel.Text = (purchaseStoredataGridView.Rows[e.RowIndex].Cells[1 + 2].Value).ToString();
                    aForm.unitnameLebel.Text = (purchaseStoredataGridView.Rows[e.RowIndex].Cells[2 + 2].Value).ToString();
                    aForm.ShowDialog();
                    LoadGridView();
                }
                if (e.ColumnIndex == 9) //when stockout
                {
                    DamageOrStockOut aForm = new DamageOrStockOut();
                    aForm.CategoryId                = Convert.ToInt32("0" + purchaseStoredataGridView.Rows[e.RowIndex].Cells[1].Value);
                    aForm.ItemId                    = Convert.ToInt32("0" + purchaseStoredataGridView.Rows[e.RowIndex].Cells[0].Value);
                    aForm.itemnamelabel.Text        = (purchaseStoredataGridView.Rows[e.RowIndex].Cells[1 + 2].Value).ToString();
                    aForm.unitnameLebel.Text        = (purchaseStoredataGridView.Rows[e.RowIndex].Cells[2 + 2].Value).ToString();
                    aForm.transactiontypelebel.Text = "Stock Out";
                    aForm.ShowDialog();
                    LoadGridView();
                }
                if (e.ColumnIndex == 10) //when damage
                {
                    DamageOrStockOut aForm = new DamageOrStockOut();
                    aForm.CategoryId                = Convert.ToInt32("0" + purchaseStoredataGridView.Rows[e.RowIndex].Cells[1].Value);
                    aForm.ItemId                    = Convert.ToInt32("0" + purchaseStoredataGridView.Rows[e.RowIndex].Cells[0].Value);
                    aForm.itemnamelabel.Text        = (purchaseStoredataGridView.Rows[e.RowIndex].Cells[1 + 2].Value).ToString();
                    aForm.unitnameLebel.Text        = (purchaseStoredataGridView.Rows[e.RowIndex].Cells[2 + 2].Value).ToString();
                    aForm.transactiontypelebel.Text = "Damage";
                    aForm.ShowDialog();
                    LoadGridView();
                }

                if (e.ColumnIndex == 11) //when delete
                {
                    DialogResult dialogResult = MessageBox.Show("Are you sure want to delete it?", "Alert!", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        StoreDAO aStoreDao = new StoreDAO();
                        string   sr        = aStoreDao.DeleteItem(Convert.ToInt32("0" + purchaseStoredataGridView.Rows[e.RowIndex].Cells[0].Value));
                        MessageBox.Show(sr);
                        LoadGridView();
                    }
                    else if (dialogResult == DialogResult.No)
                    {
                        //do something else
                    }
                }
            }
            catch (Exception)
            {
            }
        }
예제 #2
0
        private void purchaseStoredataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }
            try
            {

                if(e.ColumnIndex==8) //when purchase
                {
                    PurchaseForm aForm=new PurchaseForm();
                    aForm.CategoryId = Convert.ToInt32("0" + purchaseStoredataGridView.Rows[e.RowIndex].Cells[1].Value);
                    aForm.ItemId = Convert.ToInt32("0" + purchaseStoredataGridView.Rows[e.RowIndex].Cells[0].Value);
                    aForm.itemnamelabel.Text = ( purchaseStoredataGridView.Rows[e.RowIndex].Cells[1+2].Value).ToString();
                    aForm.unitnameLebel.Text = (purchaseStoredataGridView.Rows[e.RowIndex].Cells[2+2].Value).ToString();
                    aForm.ShowDialog();
                    LoadGridView();
                }
                if (e.ColumnIndex == 9) //when stockout
                {
                    DamageOrStockOut aForm=new DamageOrStockOut();
                    aForm.CategoryId = Convert.ToInt32("0" + purchaseStoredataGridView.Rows[e.RowIndex].Cells[1].Value);
                    aForm.ItemId = Convert.ToInt32("0" + purchaseStoredataGridView.Rows[e.RowIndex].Cells[0].Value);
                    aForm.itemnamelabel.Text = (purchaseStoredataGridView.Rows[e.RowIndex].Cells[1 + 2].Value).ToString();
                    aForm.unitnameLebel.Text = (purchaseStoredataGridView.Rows[e.RowIndex].Cells[2 + 2].Value).ToString();
                    aForm.transactiontypelebel.Text = "Stock Out";
                    aForm.ShowDialog();
                    LoadGridView();
                }
                if (e.ColumnIndex == 10) //when damage
                {
                    DamageOrStockOut aForm = new DamageOrStockOut();
                    aForm.CategoryId = Convert.ToInt32("0" + purchaseStoredataGridView.Rows[e.RowIndex].Cells[1].Value);
                    aForm.ItemId = Convert.ToInt32("0" + purchaseStoredataGridView.Rows[e.RowIndex].Cells[0].Value);
                    aForm.itemnamelabel.Text = (purchaseStoredataGridView.Rows[e.RowIndex].Cells[1 + 2].Value).ToString();
                    aForm.unitnameLebel.Text = (purchaseStoredataGridView.Rows[e.RowIndex].Cells[2 + 2].Value).ToString();
                    aForm.transactiontypelebel.Text = "Damage";
                    aForm.ShowDialog();
                    LoadGridView();
                }

                if (e.ColumnIndex == 11) //when delete
                {
                    DialogResult dialogResult = MessageBox.Show("Are you sure want to delete it?", "Alert!", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        StoreDAO aStoreDao=new StoreDAO();
                        string sr = aStoreDao.DeleteItem(Convert.ToInt32("0" + purchaseStoredataGridView.Rows[e.RowIndex].Cells[0].Value));
                        MessageBox.Show(sr);
                        LoadGridView();
                    }
                    else if (dialogResult == DialogResult.No)
                    {
                        //do something else
                    }
                }

            }
            catch (Exception)
            {

            }
        }