Example #1
0
        private void dgvPurchaseReturnBook_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                long purchaseReutrnId = 0;
                if (e.RowIndex >= 0)
                {
                    purchaseReutrnId         = Convert.ToInt64(dgvPurchaseReturnBook.CurrentRow.Cells["purchaseReutrnId"].Value);
                    dgvPurchaseItems.Visible = true;
                }
                System.Data.DataTable dtSaleChallen = TempPurchaseReturnDetailsController.getPurchaseReturnIvoiceDetails(purchaseReutrnId, Utility.FinancilaYearId);
                dgvPurchaseItems.Rows.Clear();
                dgvPurchaseItems.Rows.Add();
                foreach (DataRow dr in dtSaleChallen.Rows)
                {
                    dgvPurchaseItems.CurrentRow.Cells["itemId"].Value        = Convert.ToInt64(dr["itemId"]);
                    dgvPurchaseItems.CurrentRow.Cells["stockId"].Value       = Convert.ToInt64(0);
                    dgvPurchaseItems.CurrentRow.Cells["companyId"].Value     = Convert.ToInt32(dr["companyId"]);
                    dgvPurchaseItems.CurrentRow.Cells["categoryId"].Value    = Convert.ToString(dr["categoryId"]);
                    dgvPurchaseItems.CurrentRow.Cells["itemName"].Value      = dr["itemName"].ToString();
                    dgvPurchaseItems.CurrentRow.Cells["batchNo"].Value       = dr["batchNo"].ToString();
                    dgvPurchaseItems.CurrentRow.Cells["Quantity"].Value      = Convert.ToDouble(dr["Quantity"]);
                    dgvPurchaseItems.CurrentRow.Cells["unitBy"].Value        = dr["unitBy"].ToString();
                    dgvPurchaseItems.CurrentRow.Cells["freeQuantity"].Value  = 0;
                    dgvPurchaseItems.CurrentRow.Cells["purchaseRate"].Value  = Convert.ToString(dr["purchaseRate"]);
                    dgvPurchaseItems.CurrentRow.Cells["salesCashRate"].Value = Convert.ToString(dr["salesCashRate"]);
                    dgvPurchaseItems.CurrentRow.Cells["discount"].Value      = 0;
                    dgvPurchaseItems.CurrentRow.Cells["totalAmount"].Value   = Math.Round(Utility.ParseValue(dgvPurchaseItems.CurrentRow.Cells["Quantity"].Value.ToString()) * Utility.ParseValue(dgvPurchaseItems.CurrentRow.Cells["purchaseRate"].Value.ToString()), 2);
                    //    double discount = (Utility.ParseValue(dgvPurchaseItems.CurrentRow.Cells["discount"].Value.ToString()) * (Utility.ParseValue(dgvPurchaseItems.CurrentRow.Cells["Quantity"].Value.ToString()) * Utility.ParseValue(dgvPurchaseItems.CurrentRow.Cells["purchaseRate"].Value.ToString())) / 100);
                    double purRate = Math.Round((Convert.ToDouble(Utility.ParseValue(dgvPurchaseItems.CurrentRow.Cells["Quantity"].Value.ToString()) * Utility.ParseValue(dgvPurchaseItems.CurrentRow.Cells["purchaseRate"].Value.ToString()))), 2);

                    dgvPurchaseItems.CurrentRow.Cells["totalAmount"].Value = Math.Round(Convert.ToDouble(purRate + Utility.ParseValue(dgvPurchaseItems.CurrentRow.Cells["IGSTAmt"].Value.ToString()) - Utility.ParseValue(dgvPurchaseItems.CurrentRow.Cells["discount"].Value.ToString())), 2).ToString();
                    dgvPurchaseItems.CurrentCell = dgvPurchaseItems.CurrentRow.Cells["Quantity"];
                    dgvPurchaseItems.BeginEdit(true);
                    int col = dgvPurchaseItems.CurrentCell.ColumnIndex;
                    int row = dgvPurchaseItems.CurrentCell.RowIndex;
                    col = 0;
                    row++;
                    if (dgvPurchaseItems.Rows.Count < dtSaleChallen.Rows.Count)
                    {
                        if (row == dgvPurchaseItems.RowCount)
                        {
                            dgvPurchaseItems.Rows.Add();
                            dgvPurchaseItems.CurrentCell = dgvPurchaseItems[col + 7, row];
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #2
0
        private void btnnew_Click(object sender, EventArgs e)
        {
            try
            {
                dgvPurchaseReturnBook.DataSource = null;
                System.Data.DataTable lstPurchaseReturn = TempPurchaseReturnDetailsController.getPurchaseReturnList(Convert.ToDateTime(dtpFromDate.Value.ToShortDateString()), Convert.ToDateTime(dtpToDate.Value.ToShortDateString()), Utility.FinancilaYearId);

                if (lstPurchaseReturn.Rows.Count > 0)
                {
                    AddAutoIncrementColumn(lstPurchaseReturn);
                    System.Data.DataTable dtPurchaseReturnBook = SubTot(lstPurchaseReturn);
                    BindData(dtPurchaseReturnBook);
                }
            }
            catch (Exception ea)
            {
                MessageBox.Show(ea.Message);
            }
        }