1
私は2つのdatagridview
を持っています。第一は資産であり、第二は負債である。これを1つのdatagridview
に垂直形式で追加することは可能ですか? 私はそれらを次々と整理することしかできません。私は彼らの間に国境が必要ですdatagridview
。 まず第一にそれは可能ですか? 私のコードは、私が最小限にその幅を設定することにより、間の障壁としてのカラムを使用して、バックアップする背景色ですDatagridviewは2つの部分に分割されています
`
`ます。private void btnshow_Click(オブジェクト送信者、EventArgsの電子)
{
int a = 0, b = 0;
decimal opstk = 0, clstk = 0,val=0;
string dateas = dtpdate.Value.ToString("yyyy-MM-dd");
dataGridView1.Rows.Clear();
dataGridView2.Rows.Clear();
string qry = "select x.head_id, head_name,coalesce(op,0) as op from (select master_id, head_id, head_name, current_balance from heads where master_id='A' and not is_group order by head_id) as x left join (select head_id, sum(debit_amount-credit_amount) as op from ledger_detail ld, ledger l where ld.ledger_number=l.ledger_number and ledger_date<='"+dateas+"' group by head_id) as y on x.head_id=y.head_id order by head_id";
DataTable dt = obj.table(qry);
a = dt.Rows.Count;
for (int i = 0; i < dt.Rows.Count; i++)
{
dataGridView1.Rows.Add();
dataGridView1.Rows[i].Cells[0].Value = dt.Rows[i]["head_id"];
dataGridView1.Rows[i].Cells[1].Value = dt.Rows[i]["head_name"];
dataGridView1.Rows[i].Cells[2].Value = dt.Rows[i]["op"];
}
string qry2 = "select 'Total' as head_name,sum(op) as op from(select x.head_id, head_name,coalesce(op,0) as op from(select head_id, head_name,current_balance from heads where master_id='A' and not is_group order by head_id) as x left join (select head_id, sum(debit_amount-credit_amount) as op from ledger_detail ld, ledger l where ld.ledger_number=l.ledger_number and ledger_date<='"+dateas+"' group by head_id) as y on x.head_id=y.head_id) as z";
//string qry2 = "select 'Total' as head_name, sum(op) as op from(select x.head_id, head_name,coalesce(op,0) as op from(select head_id,head_name from heads where master_id='A'and not is_group order by head_id) as x left join (select head_id, sum(debit_amount-credit_amount) as op from ledger_detail ld, ledger l where ld.ledger_number= l.ledger_number and ledger_date<='" + dateas + "' group by head_id) as y on x.head_id=y.head_id) as z";
DataTable dt2 = obj.table(qry2);
dataGridView1.Rows.Add();
dataGridView1.Rows[a].Cells[0].Value = dt2.Rows[0]["head_name"];
dataGridView1.Rows[a].Cells[3].Value = dt2.Rows[0]["op"];
////////////////////////////////////////////////////////////////////////////////
string qry1 = "select x.head_id, head_name, coalesce(op,0) as op from (select master_id, head_id, head_name, current_balance from heads where master_id='B' and not is_group order by head_id) as x left join (select head_id, sum(debit_amount-credit_amount) as op from ledger_detail ld, ledger l where ld.ledger_number=l.ledger_number and ledger_date<='" + dateas + "' group by head_id) as y on x.head_id=y.head_id order by head_id";
DataTable dt1 = obj.table(qry1);
b = dt1.Rows.Count;
for (int i = 0; i < dt1.Rows.Count; i++)
{
dataGridView2.Rows.Add();
dataGridView2.Rows[i].Cells[0].Value = dt1.Rows[i]["head_id"];
dataGridView2.Rows[i].Cells[1].Value = dt1.Rows[i]["head_name"];
dataGridView2.Rows[i].Cells[2].Value = Convert.ToDecimal(dt1.Rows[i]["op"]) * -1;
}
string qry3 = "select 'Total' as head_name, sum(op) as op from(select x.head_id, head_name,coalesce(op,0) as op from(select head_id, head_name,current_balance from heads where master_id='B' and not is_group order by head_id) as x left join (select head_id, sum(debit_amount-credit_amount) as op from ledger_detail ld, ledger l where ld.ledger_number=l.ledger_number and ledger_date<='" + dateas + "' group by head_id) as y on x.head_id=y.head_id) as z";
DataTable dt3 = obj.table(qry3);
dataGridView2.Rows.Add();
dataGridView2.Rows[b].Cells[0].Value = dt3.Rows[0]["head_name"];
dataGridView2.Rows[b].Cells[3].Value = Convert.ToDecimal(dt3.Rows[0]["op"]) * -1;
string qry4 = "select 'Closing Stock' as head_name, sum(stock) as op from (select sum(costbase*current_stock) as stock from itemstock ik,items i where i.item_id=ik.item_id union select sum(debit-credit) as stock from view_total_trans where transdate >='"+dateas+"') as x";
DataTable dt4 = obj.table(qry4);
dataGridView1.Rows.Add();
dataGridView1.Rows[a + 1].Cells[0].Value = dt4.Rows[0]["head_name"];
dataGridView1.Rows[a + 1].Cells[3].Value = dt4.Rows[0]["op"];
opstk =Convert.ToDecimal(dataGridView1.Rows[a].Cells[3].Value) + Convert.ToDecimal(dataGridView1.Rows[a+1].Cells[3].Value);
clstk = Convert.ToDecimal(dataGridView2.Rows[b].Cells[3].Value);
val = opstk - clstk;
if(val>0)
{
dataGridView2.Rows.Add();
dataGridView2.Rows[b + 1].Cells[0].Value = "Net Loss";
dataGridView2.Rows[b + 1].Cells[3].Value = val;
dataGridView2.Rows[b + 1].DefaultCellStyle.Format = "0.00##";
dataGridView2.Rows.Add();
dataGridView2.Rows[b + 2].Cells[3].Value = clstk + val;
dataGridView2.Rows[b + 2].DefaultCellStyle.Font = new Font("Arial", 9, FontStyle.Bold);
dataGridView2.Rows[b + 2].DefaultCellStyle.Format = "0.00##";
dataGridView1.Rows.Add();
dataGridView1.Rows[a + 2].Cells[3].Value = opstk;
dataGridView1.Rows[a + 2].DefaultCellStyle.Font = new Font("Arial", 9, FontStyle.Bold);
dataGridView1.Rows[a + 2].DefaultCellStyle.Format = "0.00##";
}
else
{
dataGridView1.Rows.Add();
dataGridView1.Rows[a + 2].Cells[0].Value = "Net Profit";
dataGridView1.Rows[a + 2].Cells[3].Value = val * -1;
dataGridView1.Rows[a + 2].DefaultCellStyle.Format = "0.00##";
dataGridView2.Rows.Add();
dataGridView2.Rows[b + 1].Cells[3].Value = clstk;
dataGridView2.Rows[b + 1].DefaultCellStyle.Font = new Font("Arial", 9, FontStyle.Bold);
dataGridView2.Rows[b + 1].DefaultCellStyle.Format = "0.00##";
dataGridView1.Rows.Add();
dataGridView1.Rows[a + 3].Cells[3].Value = opstk+Convert.ToDecimal(dataGridView1.Rows[a+2].Cells[3].Value);
dataGridView1.Rows[a + 3].DefaultCellStyle.Font = new Font("Arial", 9, FontStyle.Bold);
dataGridView1.Rows[a + 3].DefaultCellStyle.Format = "0.00##";
}
}`
罫線 - だからラインを意味しますか?あなたはWindowsフォームまたはwpfを使用しますか? – Raizzen