ALTER PROCEDURE [dbo].[GetSum]
(@ID_sh int)
AS
SELECT ID_sh, SUM(price_column)
FROM tbl_mytable
WHERE @ID_sh = ID_sh
GROUP BY ID_sh
RETURN
public class Payment
{
private int _ID_sh;
public int ID_sh
{
get { return _ID_sh; }
set { _ID_sh = value; }
}
private decimal _price_column;
public decimal price_column
{
get { return _price_column; }
set { _price_column = value; }
}
private string _name;
public string name
{
get { return _name; }
set { _name = value; }
}
private string _family;
public string family
{
get { return _family; }
set { _family = value; }
}
}
public List<Payment> GetSum(string id_sh)
{
List<Payment> Pay= null;
SqlParameter[] param = new SqlParameter[]
{
new SqlParameter("@ID_sh",id_sh)
};
using (DataTable table = SqlDBHelper.ExecuteSelectParameterCommand("GetSum" , CommandType.StoredProcedure, param))
{
if (table.Rows.Count > 0)
{
PaymentList= new List<Payment>();
foreach (DataRow row in table.Rows)
{
Payment Pay = new Payment ();
PaymentList.Add(Pay );
}
}
else
{
return PaymentList;
}
}
return PaymentList;
}
public List<Payment> GetSum(string id_sh)
{
return PaymentDB.GetSum(shp);
}
protected void btn_ShowSum_Click(object sender, ImageClickEventArgs e)
{
DAL.Payment pay = new DAL.Payment ();
shp = lbl_kod.Text + txt_sh.Text;
pay.ID_sh = shp;
PaymentDB.GetSum(pay.ID_sh);
txtShowSum.Text = pay.price_column.ToString();
}
pay.ID_sh = Convert.ToInt32(row["ID_sh"]);
pay.price_column = Convert.Todecimal(row["price_column"]);
برچسب:
نویسنده: خنج