using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Organization_Settings_Organization_LeaveSettingsDepartment : System.Web.UI.Page
{
    DataSet dsDepartmentDetails = new DataSet();
    LeaveSettingsEventData_Angler objLeaveSettingsEventData = new LeaveSettingsEventData_Angler();
    cls_Common objClassCommon = new cls_Common();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            grv_Departments.DataSourceID = "";
            bindDepartmentDetails();
            objClassCommon.menu("LeaveSettings", "Departments ");
        }
        site.SiteMapProvider = Convert.ToString(Session["SiteMapProvider"]);
    }
    protected void grv_Departments_RowEditing(object sender, GridViewEditEventArgs e)
    {
        grv_Departments.EditIndex = e.NewEditIndex;
        lblError.Text = "";
        bindDepartmentDetails();
    }
    protected void grv_Departments_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        Label lbl_LevelId = (Label)grv_Departments.Rows[e.RowIndex].FindControl("lblLevelId");
        TextBox txtToMaildIds = (TextBox)grv_Departments.Rows[e.RowIndex].FindControl("txt_ToMaildIds");
        TextBox txtCCMailIds = (TextBox)grv_Departments.Rows[e.RowIndex].FindControl("txt_CCMaildIds");

        //Update Department To and CC mail Ids
        objLeaveSettingsEventData.UpdateDepartmentToCCMailIds(Convert.ToInt32(lbl_LevelId.Text), txtToMaildIds.Text, txtCCMailIds.Text);
        grv_Departments.EditIndex = -1;
        bindDepartmentDetails();      
    }
    protected void grv_Departments_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        grv_Departments.EditIndex = -1;
        lblError.Text = "";
        bindDepartmentDetails();
    }

    public void bindDepartmentDetails()
    {
        dsDepartmentDetails = objLeaveSettingsEventData.GetDepartmentMailIds(0);
        grv_Departments.DataSource = dsDepartmentDetails;
        grv_Departments.DataBind();
    }
    protected void grv_Departments_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            // The column which the wrapping of single word should be applied
           
            e.Row.Cells[2].Attributes.Add("style", "word-break:break-all;word-wrap:break-word");
            e.Row.Cells[3].Attributes.Add("style", "word-break:break-all;word-wrap:break-word");
        }
    }
    protected void btn_Cancel_Click(object sender, EventArgs e)
    {
        Response.Redirect("Organization_LeaveSettings.aspx");
    }


}
