Click here to Skip to main content
15,896,269 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C#
Sqlstr  = "select sum(sal_det_amt) as unpaidleaveamt from salary_details where comp_id = "+strCompanyid+
       " and sal_isdeduct = 1 and sal_det_desc LIKE 'Unpaid Leave%' and sal_id IN "+
       "(select sal_id from salary_master where  comp_id = "+strCompanyid +" and sal_year = " + lngPreviousYear +
       " and emp_code = '" + Txt_Employee.Text + "')";
       strUnpaidLeaveAmt = cfs.get_data(Sqlstr);
       if(strUnpaidLeaveAmt.Trim() !=string.Empty && cfs.IsNumeric(strUnpaidLeaveAmt))
       {
           dblTempUnpaidLeaveAmt = cfs.IsNumber(strUnpaidLeaveAmt);
       }
       if( dblTotalSalary > 0 )
       {
          // TxtAmounts(0).Text = dblTotalSalary - dblTempUnpaidLeaveAmt;
       }
       strBonus = string.Empty; strBonusDate = string.Empty;
Posted
Updated 26-Aug-14 22:49pm
v2

See this : Calling Stored procedures in ADO.NET[^]

Move your query to the stored procedure and you are done.

Regards..
 
Share this answer
 
create procedure Procname
@Companyid int,
@previousyear int,
@empcode varchar(50),
@unpaidleaveamt money output
AS
BEGIN
select @unpaidleaveamt=sum(sal_det_amt) from salary_details where comp_id = @CompanyId and sal_isdeduct = 1 and sal_det_desc LIKE 'Unpaid Leave%' and sal_id IN
(select sal_id from salary_master where comp_id = @CompanyId and sal_year = @previousyear and emp_code =@empcode)
END
 
Share this answer
 
Comments
Member 10928697 27-Aug-14 7:27am    
Sqlstr = "select sum(sal_bonus) as bonusamt from salary_master where sal_deleted = 0 "+
" and year(sal_bonusdate) = " + lngPreviousYear + " and comp_id = " + strCompanyid +
" and emp_code = '" + Txt_Employee.Text+ "'" ;
if (vpcn.gbHalfSalary == true)
{
Sqlstr += " and sal_type = '" + vpcn.cSalary_2Half + "' ";
}
strBonus = cfs.get_data(Sqlstr);
plz tell me query
ClimerChinna 27-Aug-14 7:29am    
you need query or procedure
ClimerChinna 27-Aug-14 7:30am    
you are giving the fields from your code with out explaining about them for us,how could we know what is what , and how could we wrtie query for you with out knowing any of your fields,, try to ask question clearly
Member 10928697 27-Aug-14 7:32am    
How to write stored procedure in the below query
------------------------------------------------
Sqlstr = "select sum(sal_bonus) as bonusamt from salary_master where sal_deleted = 0 "+
" and year(sal_bonusdate) = " + lngPreviousYear + " and comp_id = " + strCompanyid +
" and emp_code = '" + Txt_Employee.Text+ "'" ;
if (vpcn.gbHalfSalary == true)
{
Sqlstr += " and sal_type = '" + vpcn.cSalary_2Half + "' ";
}
strBonus = cfs.get_data(Sqlstr);
plz tell me query

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900