Example #1
0
 private void btnShow_Click(object sender, EventArgs e)
 {
     try
     {
         //string query = "select s.saleId,s.BillNo as Bill_No,CONVERT(VARCHAR(11),s.BillDate,106) as Bill_Date,c.Customer,s.CBalance,s.GrandTotal as Bill_Amount,s.Balance from tblSales s,tblCustomer c where s.custId=c.Custid  and s.BillDate>='" + DtFrom.Value.ToString("dd-MMM-yyyy") + "' and s.BillDate<='" + DtTo.Value.ToString("dd-MMM-yyyy") + "'";
         string query = "select s.saleId,c.Customer,s.BillNo as Bill_No,s.GrandTotal as Bill_Amount,CASE WHEN s.BillNo IS NULL THEN c.creditBal ELSE s.CBalance END AS Prev_Balance,s.Balance from tblCustomer  c left join tblSales  s on c.custId = s.Custid and c.areaId ='" + cboArea.SelectedValue + "'  and  s.BillDate>='" + DtFrom.Value.ToString("dd-MMM-yyyy") + "' and s.BillDate<='" + DtTo.Value.ToString("dd-MMM-yyyy") + "' and s.areaId='" + cboArea.SelectedValue + "'  where c.areaid='" + cboArea.SelectedValue + "' order by c.Customer";
         System.Data.DataColumn area = new System.Data.DataColumn("Area", typeof(System.String));
         area.DefaultValue = cboArea.Text;
         System.Data.DataColumn DateFrom = new System.Data.DataColumn("DateFrom", typeof(System.String));
         DateFrom.DefaultValue = DtFrom.Value.ToString("dd-MMM-yyyy");
         System.Data.DataColumn DateTo = new System.Data.DataColumn("DateTo", typeof(System.String));
         DateTo.DefaultValue = DtTo.Value.ToString("dd-MMM-yyyy");
         DataTable dt = (DataTable)Connections.Instance.ShowDataInGridView(query);
         dt.Columns.Add(area);
         dt.Columns.Add(DateFrom);
         dt.Columns.Add(DateTo);
         ds.Tables["SaleSheet"].Clear();
         ds.Tables["SaleSheet"].Merge(dt);
         ItemGrid.Columns.Clear();
         ItemGrid.DataSource              = null;
         ItemGrid.DataSource              = Connections.Instance.ShowDataInGridView(query);
         ItemGrid.Columns[0].Visible      = false;
         ItemGrid.Columns[1].MinimumWidth = 350;
         ItemGrid.Columns[5].HeaderText   = "Total";
         ItemGrid.Columns.Add("Cash", "Cash");
         ItemGrid.Columns.Add("Discounts", "Discounts");
         ItemGrid.Columns.Add("Bal", "Balance");
         ItemGrid.CurrentCell = ItemGrid.Rows[0].Cells[6];
         ItemGrid.BeginEdit(true);
     }
     catch { }
 }
Example #2
0
        private void Control_Leave(object sender, EventArgs e)
        {
            int iColumn = ItemGrid.CurrentCell.ColumnIndex;
            int iRow    = ItemGrid.CurrentCell.RowIndex;

            if (iColumn == ItemGrid.Columns.Count - 1)
            {
                ItemGrid.CurrentCell = ItemGrid[0, iRow + 1];
            }
            else
            {
                ItemGrid.CurrentCell = ItemGrid[iColumn + 1, iRow];
            }
            ItemGrid.BeginEdit(true);
        }