protected void Checksalary()
    {
        try
        {
            btnsave.Text         = "Update";
            HiddenSalaryId.Value = Request.QueryString["SI_DetailsId"];
            Int64 SalaryDetailsId = Convert.ToInt64(Request.QueryString["SI_DetailsId"]);

            TMSSalaryDetails obj = TMSSalaryDetails.Get(Convert.ToInt64(SalaryDetailsId));

            if (obj.SISalaryType != null)
            {
                if (obj.SISalaryType == "Monthly")
                {
                    rbtmonth.Checked = true;
                }
                else
                {
                    rbtYear.Checked = true;
                }
            }
            // txtBasicSalary.Text = obj.SIBasicSalary.ToString();
            txtGrossSalary.Text           = obj.SIGrossSalary.ToString();
            txtLeaveCount.Text            = obj.SILeaveCount.ToString();
            txtDeductionAmt.Text          = obj.SILeaveDeductionAmount.ToString();
            ddlMonth.SelectedValue        = obj.SIMonth.ToString();
            ddlYear.SelectedValue         = obj.SIYear.ToString();
            ddlSalaryStatus.SelectedValue = obj.SIAddedByRemarks.ToString();
        }
        catch (Exception ex) { }
    }
    protected void btnsave_Click(object sender, EventArgs e)
    {
        try
        {
            Int64          FacultyTypeId = Convert.ToInt64(Session["FacultyType"]);
            TMSFacultyType objType       = TMSFacultyType.Get(FacultyTypeId);
            string         FacultyType   = null;
            if (objType != null)
            {
                FacultyType = objType.FTFacultyName;
            }

            if (btnsave.Text == "Update")
            {
                TMSSalaryDetails objSalary = TMSSalaryDetails.Get(Convert.ToInt64(HiddenSalaryId.Value));
                objSalary.SIFacultyLoginId = Convert.ToInt64(Session["AccountID"]);
                if (rbtmonth.Checked == true)
                {
                    objSalary.SISalaryType = "Monthly";
                }
                else if (rbtYear.Checked == true)
                {
                    objSalary.SISalaryType = "Yearly";
                }
                objSalary.SIFacultyType = Session["FacultyType"].ToString();
                objSalary.SIFacultyType = Session["FacultyType"].ToString();
                //
                objSalary.SIGrossSalary          = float.Parse(txtGrossSalary.Text);
                objSalary.SILeaveCount           = Convert.ToInt32(txtLeaveCount.Text);
                objSalary.SILeaveDeductionAmount = float.Parse(txtDeductionAmt.Text);
                objSalary.SIMonth          = ddlMonth.SelectedItem.Text;
                objSalary.SIYear           = ddlYear.SelectedItem.Text;
                objSalary.SIAddedByRemarks = ddlSalaryStatus.SelectedItem.Text;
                objSalary.SIOtherRemarks   = FacultyType + " " + "Salary";
                objSalary.SIAddedById      = Convert.ToInt64(Session["UserId"]);
                objSalary.SIDate           = DateTime.Now;

                if (txtDeductionAmt.Text != "")
                {
                    objSalary.SIBasicSalary = float.Parse(txtGrossSalary.Text) - float.Parse(txtDeductionAmt.Text);
                }

                else
                {
                    objSalary.SIBasicSalary = float.Parse(txtGrossSalary.Text);
                }
                objSalary.Update();
                if (FacultyType == "Teacher")
                {
                    Response.Redirect("ViewSalaryDetails.aspx?msg=Teacher Salary Details  Updated Successfully !");
                }
                else
                {
                    Response.Redirect("ViewSalaryDetails.aspx?msg=Staff Salary Details  Updated Successfully !");
                }
                //  Response.Redirect("ViewSalaryDetails.aspx?msg=Salary Details  Updated Successfully !");
            }

            else
            {
                DataTable dt = TMSSalaryDetails.GetSalaryDetails(null, Convert.ToInt64(Session["AccountID"]), Session["FacultyType"].ToString(), null, ddlMonth.SelectedItem.Text, ddlYear.SelectedItem.Text).Tables[0];

                if (dt.Rows.Count > 0)
                {
                    dvMsg.Visible   = true;
                    lblMessage.Text = "Salary Details Already Added for this Month and Year !";
                    dvMsg.Attributes.Add("class", "error_msg");
                    return;
                }
                else
                {
                    TMSSalaryDetails objSalary = new TMSSalaryDetails();
                    objSalary.SIFacultyLoginId = Convert.ToInt64(Session["AccountID"]);
                    if (rbtmonth.Checked == true)
                    {
                        objSalary.SISalaryType = "Monthly";
                    }
                    else if (rbtYear.Checked == true)
                    {
                        objSalary.SISalaryType = "Yearly";
                    }
                    objSalary.SIFacultyType = Session["FacultyType"].ToString();

                    objSalary.SIGrossSalary          = float.Parse(txtGrossSalary.Text);
                    objSalary.SILeaveCount           = Convert.ToInt32(txtLeaveCount.Text);
                    objSalary.SILeaveDeductionAmount = float.Parse(txtDeductionAmt.Text);

                    if (txtDeductionAmt.Text != "")
                    {
                        objSalary.SIBasicSalary = float.Parse(txtGrossSalary.Text) - float.Parse(txtDeductionAmt.Text);
                    }

                    else
                    {
                        objSalary.SIBasicSalary = float.Parse(txtGrossSalary.Text);
                    }
                    objSalary.SIMonth          = ddlMonth.SelectedItem.Text;
                    objSalary.SIYear           = ddlYear.SelectedItem.Text;
                    objSalary.SIAddedByRemarks = ddlSalaryStatus.SelectedItem.Text;
                    objSalary.SIOtherRemarks   = FacultyType + " " + "Salary";
                    objSalary.SIAddedById      = Convert.ToInt64(Session["UserId"]);
                    objSalary.SIDate           = DateTime.Now;
                    objSalary.SIStatus         = 1;
                    objSalary.Insert();
                    if (FacultyType == "Teacher")
                    {
                        Response.Redirect("ViewSalaryDetails.aspx?msg=Teacher Salary Details  Added Successfully !");
                    }
                    else
                    {
                        Response.Redirect("ViewSalaryDetails.aspx?msg=Staff Salary Details  Added Successfully !");
                    }
                }
            }
        }
        catch (Exception ex) { }
        {
        }
    }