如何从一个数据网格视图查找未付费的客户记录? [英] How to find unpaid customer records from one datagridview to another?

查看:93
本文介绍了如何从一个数据网格视图查找未付费的客户记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我正在为datagridview寻找一个解决方案。两个datagridview是一个dg1和第二个dg2。一个组合框和一个按钮也在那里。现在我想查询解决方案,比如,



当我从组合框中选择1月并在此之后点击按钮,作为输出我可以显示来自的付费和未付费客户记录数据库在dg1和dg2。



所以基本上,当我选择1月份时,我可以将dg1视为客户的付费记录,dg2作为未付的客户记录。



请帮助我如果有任何人解决我的问题,那么我当前的工作项目。



谢谢&此致,

Vaishali Parmar。



我的尝试:



i在行下方添加了combobox月,



Hello,

I am looking for a one solution for datagridview. two datagridview is there one dg1 and second dg2. one combobox and one button is also there. Now I want to query solution like,

When i select january from combobox and click on button after that, as output I can able to show paid and unpaid customer record from the database in dg1 and dg2.

so basically, when i select january month i can able to see dg1 as paid record of customer and dg2 as unpaid record of customer.

Please Help me If any one have solution of my problem then for my current working project.

Thanks & Regards,
Vaishali Parmar.

What I have tried:

i added combobox months by below line,

cyear.DataSource = System.Globalization.DateTimeFormatInfo.InvariantInfo.MonthNames

推荐答案

Create PROCEDURE SPtblStatus
	@Month	varchar(50)	=null
		
AS
BEGIN
	select * from Codeproject.tblStatus where Status='Paid' and Month=@Month
	select * from Codeproject.tblStatus where Status='UnPaid' and Month=@Month
END
GO





此存储过程返回两个结果。将这些应用到应用程序中。





This stored procedure returns two results. get those into application.

DataSet ds = new DataSet();
           using (var con = new SqlConnection("Data Source=DESKTOP-0V1BRD9;Initial Catalog=StackOverflow;Persist Security Info=True;User ID=sa;Password=sa_123+"))
           using (var cmd = new SqlCommand("SPtblStatus", con))
           using (var da = new SqlDataAdapter(cmd))
           {
               cmd.CommandType = CommandType.StoredProcedure;
               SqlParameter param = new SqlParameter("@Month", "Feb");
               cmd.Parameters.Add(param);
               da.Fill(ds);
           }

           if (ds.Tables.Count > 0)
           {
               dataGridView1.DataSource = ds.Tables[0];
               dataGridView2.DataSource = ds.Tables[1];
           }


这篇关于如何从一个数据网格视图查找未付费的客户记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆