Click here to Skip to main content
15,911,711 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
for (int i = 0; i < gvLeaveBank.Rows.Count; i++)
            {

                double dblTaken = 0, dblBalance = 0, dblLastYear = 0, dblCurrentyear = 0, dblNoOfDays = 0;
                Label lblLastyear2013 = (Label)gvLeaveBank.Rows[i].FindControl("lblLastyear2013");
                Label lblCurrentyear2014 = (Label)gvLeaveBank.Rows[i].FindControl("lblCurrentyear2014");
             //Label lblNoOfDays = (Label)gvLeaveBank.Rows[i].FindControl("lblNoOfDays");
                Label lblTakenDays = (Label)gvLeaveBank.Rows[i].FindControl("lblTakenDays");
                Label lblRemainingDays = (Label)gvLeaveBank.Rows[i].FindControl("lblRemainingDays");
                Label lblLeaveType = (Label)gvLeaveBank.Rows[i].FindControl("lblLeaveType");

               dblBalance = (dblLastYear + dblCurrentyear) - dblTaken;
                string LvTypeId = "";
                BBEL.lv_type_name = lblLeaveType.Text;
                //BBEL.comp_id = Convert.ToInt16(Session["compid"]);
                //BBEL.lv_type_id = Convert.ToInt16(Session["LvTypeId"]);

                     DataSet dt = new DataSet();
            DBUtilities db = new DBUtilities();
            SqlParameter[] parameters = new SqlParameter[]
		        {
                     new SqlParameter("@lv_type_name", BBEL.lv_type_name),
                     // new SqlParameter("@lv_type_id", BBEL.lv_type_id),
                      //new SqlParameter("@comp_id", BBEL.comp_id)
                };
            dt = db.ExecuteParamerizedSelectCommandDataset("sp_getLeaveID1", CommandType.StoredProcedure, parameters);
            try
            {
                LvTypeId = dt.Tables[0].Rows[0][0].ToString();

            }
            catch
            { }
                BBEL.lq_leave_prev_days = Convert.ToDecimal(lblLastyear2013.Text);
                BBEL.lq_leave_days = Convert.ToDecimal(lblCurrentyear2014.Text);
             // BBEL.lq_leave_days = Convert.ToDecimal(lblNoOfDays.Text);
                BBEL.lq_leave_taken = Convert.ToDecimal(lblTakenDays.Text);
                BBEL.lq_leave_balance = Convert.ToDecimal(lblRemainingDays.Text);
                BBEL.comp_id = Convert.ToInt16(Session["compid"]);
                BBEL.emp_code = txtEmpCode.Text;
             // BBEL.lv_type_id = Convert.ToInt16(Session["LvTypeId"]);
             // BBEL.lv_type_name = txtEmpName.Text;
                BBEL.lv_type_id = Convert.ToInt16(LvTypeId);
                BBEL.lq_year = Convert.ToInt16(ddlYear.SelectedItem.Text);
             // BBLL.UpdateEmpLeaveQuota(BBEL);
                if (BBLL.UpdateEmpLeaveQuota1(BBEL) == true)
                {

                //   // ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "LeaveRequest", "alert('LeaveRequest details Updated successfully');", true);

                }
            }
            btnGetList_Click(sender, e);

        }

[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 17-Aug-14 20:57pm
v2
Comments
Prasad Avunoori 18-Aug-14 2:57am    
Are you getting any error?
Member 10928697 18-Aug-14 7:07am    
i got an error ------BBEL.lv_type_id = Convert.ToInt16(LvTypeId);
input string was not currect formet
Prasad Avunoori 18-Aug-14 7:11am    
LvTypeId has Non Integer value it seems.
Member 10928697 18-Aug-14 7:36am    
thanku

1 solution

Like that, it doesn't compile - so it won't save as it isn't running that code.
For starters, remove the comma here:
C#
SqlParameter[] parameters = new SqlParameter[]
    {
         new SqlParameter("@lv_type_name", BBEL.lv_type_name),
         // new SqlParameter("@lv_type_id", BBEL.lv_type_id),
          //new SqlParameter("@comp_id", BBEL.comp_id)
    };
So it will compile:
C#
SqlParameter[] parameters = new SqlParameter[]
    {
         new SqlParameter("@lv_type_name", BBEL.lv_type_name)
         // new SqlParameter("@lv_type_id", BBEL.lv_type_id),
          //new SqlParameter("@comp_id", BBEL.comp_id)
    };
But I'd guess that you get an error from SQL you aren;t catching as well, given that two of the parameters the SP is probably expecting are commented out...
 
Share this answer
 
Comments
Member 10928697 18-Aug-14 7:08am    
r u right..sp was not currect formet
Member 10928697 20-Aug-14 7:29am    
ALTER Procedure [dbo].[sp_LeaveSummaryGetAll]

@comp_id int,
@lq_year int,
@emp_id nvarchar(200),
@leave_type_name nvarchar(200),
@emp_chk int,
@lv_chk int
As
Begin
if(@emp_chk=1)
begin
if(@lv_chk=1)
begin
SELECT leave_id,a.emp_code as [Emp Code],b.emp_fname as [Emp Name],c.lv_type_name as [Leave Type],convert(varchar (10), leave_start_time,103) as [From Date],convert(varchar (10), leave_end_time,103) as [To Date],
a.leave_days,a.leave_status as [Status],a.leave_doneby as [Doneby],a.leave_balance_days as [Available Leaves] FROM Leave a, employee as b,
LeaveTypes as c ,Emp_Leave_Quota as d
where d.comp_id = a.comp_id And d.emp_code = a.emp_code And d.lv_type_id = a.leave_type_id
and d.lq_year = year(a.leave_date)
and c.lv_type_id = a.leave_type_id
and b.comp_id = a.comp_id and b.emp_code = a.emp_code
and a.leave_deleted = 0 and a.comp_id = @comp_id and year(leave_date)=@lq_year
end
else
begin
SELECT leave_id,a.emp_code as [Emp Code],b.emp_fname as [Emp Name],c.lv_type_name as [Leave Type],convert(varchar (10), leave_start_time,103) as [From Date],convert(varchar (10),leave_end_time,103) as [To Date],
a.leave_days,a.leave_status as [Status],a.leave_doneby as [Doneby],a.leave_balance_days as [Available Leaves] FROM Leave a, employee as b,
LeaveTypes as c ,Emp_Leave_Quota as d
where d.comp_id = a.comp_id And d.emp_code = a.emp_code And d.lv_type_id = a.leave_type_id
and d.lq_year = year(a.leave_date)
and c.lv_type_code = a.leave_type_id
and b.comp_id = a.comp_id and b.emp_code = a.emp_code
and a.leave_deleted = 0 and a.comp_id = @comp_id and year(leave_date)=@lq_year
and c.lv_type_name =@leave_type_name

end
end
else
begin
if(@lv_chk=1)
begin
SELECT leave_id,a.emp_code as [Emp Code],b.emp_fname as [Emp Name],c.lv_type_name as [Leave Type],convert(varchar (10), leave_start_time,103) as [From Date],convert(varchar (10),leave_end_time,103) as [To Date],
a.leave_days,a.leave_status as [Status],a.leave_doneby as [Doneby],a.leave_balance_days as [Available Leaves] FROM Leave a, employee as b,
LeaveTypes as c ,Emp_Leave_Quota as d
where d.comp_id = a.comp_id And d.emp_code = a.emp_code And d.lv_type_id = a.leave_type_id
and d.lq_year = year(a.leave_date)
and c.lv_type_code = a.leave_type_id
and b.comp_id = a.comp_id and b.emp_code = a.emp_code
and a.leave_deleted = 0 and a.comp_id = @comp_id and year(leave_date)=@lq_year and
a.emp_code=@emp_id
end
else
begin
SELECT leave_id,a.emp_code as [Emp Code],b.emp_fname as [Emp Name],c.lv_type_name as [Leave Type],convert(varchar (10), leave_start_time,103) as [From Date],convert(varchar (10),leave_end_time,103) as [To Date],
a.leave_days,a.leave_status as [Status],a.leave_doneby as [Doneby],a.leave_balance_days as [Available Leaves] FROM Leave a, employee as b,
LeaveTypes as c ,Emp_Leave_Quota as d
where d.comp_id = a.comp_id And d.emp_code = a.emp_code And d.lv_type_id = a.leave_type_id
and d.lq_year = year(a.leave_date)
and c.lv_type_code = a.leave_type_id
and b.comp_id = a.comp_id and b.emp_code = a.emp_code
and a.leave_deleted = 0 and a.comp_id = @comp_id and year(leave_date)=@lq_year
and c.lv_type_name =@leave_type_name and a.emp_code=@emp_id
end
end
end
this is my stored procedure plz slove
OriginalGriff 20-Aug-14 7:35am    
Solve what?
I have no idea what it does or doesn't do, what it should or shouldn't do, what tables it is meant to work on, what values you are passing it, or any access to your DB so I can find out!

Open a new question, include all relevant information, and someone will take a look at it.
Member 10928697 20-Aug-14 7:40am    
ok tq.
Member 10928697 20-Aug-14 7:50am    
sry..
this is table.
lq_id int
lq_year int
lv_type_id
comp_id int
emp_code
lq_leave_days
lq_leave_taken
lq_leave_balance
lq_createdby
lq_createddate
lq_updatedby
lq_updateddate
lq_deleted
lq_leave_prev_days
..
this is windows form
------------------
private void Btn_GetList_Click(object sender, EventArgs e)
{
strSql = "SELECT leave_id,a.emp_code as [Emp Code],b.emp_fname as [Employee],c.lv_type_name as [Leave Type], leave_start_time as [From Date],leave_end_time as [To Date],";
strSql += "a.leave_days as [No.of Days],a.leave_status as [Status],a.leave_doneby as [Doneby],a.leave_balance_days as [Available Days] FROM Leave a, employee as b,";
strSql += " LeaveTypes as c ,Emp_Leave_Quota as d ";
strSql += " where a.emp_code='"+strUid+"' and d.comp_id = a.comp_id And d.emp_code = a.emp_code And d.lv_type_id = a.leave_type_id";
strSql += " and d.lq_year = year(a.leave_date) ";
strSql += " and c.lv_type_id = a.leave_type_id ";
strSql += " and b.comp_id = a.comp_id and b.emp_code = a.emp_code";
strSql += " and a.leave_deleted = 0 and a.comp_id = '" + strCompanyid + "'";

if (Cb_Year.Text != "")
strSql += " and year(leave_date) = '" + Cb_Year.Text + "'";
else
strSql += " and year(leave_date) = '" + Cb_Year.Text + "'";
//if (Cb_EmpLeaveType.SelectedValue.ToString() != "ALL") strSql += " and a.leave_type_id = '" + Cb_EmpLeaveType.SelectedValue.ToString() + "'";


if (Cb_EmpLeaveType.Text != "ALL") strSql += " and c.lv_type_name = '" + Cb_EmpLeaveType.Text + "'";
Cursor = Cursors.WaitCursor;
dap = new SqlDataAdapter(strSql, cn);
sqlcommbuild = new SqlCommandBuilder(dap);
dtblTemp = new DataTable();
dap.Fill(dtblTemp);
bindsrc = new BindingSource();
bindsrc.DataSource = dtblTemp;
Dgv_Summary.DataSource = bindsrc;
//dataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
Dgv_Summary.Columns[0].Visible = false;
Dgv_Summary.Columns[1].Visible = false;
Cursor = Cursors.Default;

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