using System;
using System.Data;
using System.Globalization;
using System.Resources;
using System.Threading;
using System.Web.UI;
/****************************************************************************************************************************
* Project Name    : TimeCheck                                   Started Date  : 12-Aug-2007
* Module          : Vehicle Master                              Last Modified : 14-Aug-2007
* Programmer      : 
* Current Storage : \\Angler56\Projects\Inprogress\SCREEN1206\code\Time_AttendanceApp
* BackUp          :
****************************************************************************************************************************/
public partial class Master_TA_UI_MasterTransportationVehicleAdd : Base.BasePage
{
    #region VariableDeclaration
    ResourceManager rm;
    CultureInfo ci;
    Cls_CheckUser objCheckUser = new Cls_CheckUser();
    cls_Common objCommon = new cls_Common();
    DataSet ds_Checkuser = new DataSet();
    string strSetAlert;
    cls_Master_Transportation objTransportationVehicle = new cls_Master_Transportation();
    int Count, EmployeeID;
    #endregion
    #region PageLoad
    protected override void Page_Load(object sender, EventArgs e)
    {
        // session checking
        base.Page_Load(sender, e);
        //get the culture info to set the language
        string source_Language;
        source_Language = Convert.ToString(Session["Session_ActiveLanguage"]);
        rm = new ResourceManager(source_Language, System.Reflection.Assembly.Load("App_GlobalResources"));
        ci = Thread.CurrentThread.CurrentCulture;
        site.SiteMapProvider = Convert.ToString(Session["SiteMapProvider"]);
        // LoadStrings Function fills the Label from the Resource File
        LoadStrings(ci);
        //Set UserRights
        UserRights();
        txtVehicleNo.Focus();
        EmployeeID = Convert.ToInt32(Session["EmpAutoID"].ToString());
        btn_save.OnClientClick = "if(Page_ClientValidate()) return confirm('" + rm.GetString("Alert_ConfirmSave", ci) + "');return false;";
        if (!IsPostBack)
        {
            strSetAlert = strSetAlert + "<script language='javascript'>";
            strSetAlert = strSetAlert + "MaxLengthh('" + rm.GetString("Alert_MaximumLengthis", ci) + "');";
            strSetAlert = strSetAlert + "</script>";
            Page.RegisterStartupScript("MaxLengthh", strSetAlert);
            objCommon.menu("Transportation", "230");
        }
    }
    #endregion
    #region ButtonEvents
    protected void btn_save_Click(object sender, EventArgs e)
    {
        Count = objTransportationVehicle.CheckVehicleNO_Insert(txtVehicleNo.Text.Trim().Replace("'", "''"));
        if (Count == 0)
        {
            objTransportationVehicle.InsertTransportationVehicleDetails(txtVehicleNo.Text.Trim().Replace("'", "''"), txtVehicleDesc.Text.Trim().Replace("'", "''"), EmployeeID);
            base.MessageWithRedirect(rm.GetString("Vehicle_savedsuccessfully", ci), "TA_UI_MasterTransportationVehicleList.aspx");
        }
        else
        {
            base.Message(rm.GetString("Vehicle_Master_Vehicle_No_Already_Exits", ci));
        }
    }
    protected void btn_Cancel_Click(object sender, EventArgs e)
    {
        Response.Redirect("TA_UI_MasterTransportationVehicleList.aspx");
    }
    #endregion
    #region UserDefinedFunctions
    //Getting Information from resource file and display it in label
    private void LoadStrings(CultureInfo ci)
    {
        lbl_VehicleNo.Text = rm.GetString("Vehicle_Master_Vehicle_No", ci);
        lbl_VehicleDescription.Text = rm.GetString("Vehicle_Master_Vehicle_Desc", ci);
        lbl_IndicatesMandatoryFields.Text = rm.GetString("IndicatesMandatoryFields", ci);
        ReqVehNo.ErrorMessage = rm.GetString("Validator_Vehicle_VehicleNo", ci);
        lbl_TransportationVehicle.Text = rm.GetString("Masters_Transportation_Vehicle_Master", ci);
        btn_save.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Save", ci);
        btn_Cancel.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Back", ci);
    }
    private void UserRights()
    {
        ds_Checkuser = objCheckUser.checkRights(12, Convert.ToInt32(Session["userGroup_Id"]), "addPrv");
        if (ds_Checkuser.Tables[0].Rows.Count == 0)
        {
            Response.Redirect("MasterLandingPage.aspx");
        }
    }
    #endregion
}