예제 #1
0
        private void dvStock_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;

            var aa = dvStock.CurrentCell.RowIndex;

            if ((senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn) && (senderGrid.Columns[e.ColumnIndex].DisplayIndex == 16 && e.RowIndex >= 0) && (!(String.IsNullOrEmpty(dvStock.Rows[aa].Cells[18].Value.ToString()))))
            {
                stockID = Convert.ToInt32(dvStock.Rows[aa].Cells[18].Value);
                DataTable dtStock = new DataTable();
                dtStock = stockBLL.GetAllStock(stockID);
                cmbSize.SelectedValue    = dtStock.Rows[0]["SizeID"].ToString();
                cmbTax.SelectedValue     = dtStock.Rows[0]["TaxID"].ToString();
                txtMake.Text             = dtStock.Rows[0]["Make"].ToString();
                txtQuantity.Text         = dtStock.Rows[0]["Quantity"].ToString();
                cbUnit.SelectedValue     = dtStock.Rows[0]["UnitID"].ToString();
                txtRate.Text             = dtStock.Rows[0]["RatePerUnit"].ToString();
                cmbSize.SelectedValue    = dtStock.Rows[0]["SizeID"].ToString();
                txtTaxPer.Text           = dtStock.Rows[0]["TaxPercentage"].ToString();
                txtTaxAmount.Text        = dtStock.Rows[0]["TaxAmount"].ToString();
                txtDiscount.Text         = dtStock.Rows[0]["Discount"].ToString();
                txtDiscountAmount.Text   = dtStock.Rows[0]["DiscountAmount"].ToString();
                txtRemark.Text           = dtStock.Rows[0]["Remark"].ToString();
                txtTotalAmount.Text      = dtStock.Rows[0]["TotalAmount"].ToString();
                cmbProduct.SelectedValue = dtStock.Rows[0]["ProductID"].ToString();
            }
            else if ((senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn) && (senderGrid.Columns[e.ColumnIndex].DisplayIndex == 17 && e.RowIndex >= 0) && (!(String.IsNullOrEmpty(dvStock.Rows[aa].Cells[18].Value.ToString()))))
            {
                if (ShowDeleteConfirmMessage())
                {
                    stockID = Convert.ToInt32(dvStock.Rows[aa].Cells[18].Value);
                    bool check = stockBLL.StockDelete(stockID, DateTime.Now, UserId);
                    if (check == true)
                    {
                        MessageBox.Show("Selected stock Deleted Successfully.");
                    }
                    else
                    {
                        MessageBox.Show("Selected stock cannot be deleted due to maaping with other masters.");
                    }
                }
                ClearFields();
            }
            FillGrid();
        }