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

/// <summary>
/// Summary description for Class_tblUserTypes
/// </summary>
public class Class_tblUserTypes
{
    
    private String Str_UserTypeDescription = String.Empty;

    public Class_tblUserTypes( String Str_UserTypeDescription)
	{
     
        this.Str_UserTypeDescription = Str_UserTypeDescription;
	}

    public void UDF_SaveAzTypeUser()
    {
        LSC_WareHouseDataContext db = new LSC_WareHouseDataContext();
        tblUserType userType = new tblUserType();

        
        userType.UserTypeDescription = Str_UserTypeDescription;

        db.tblUserTypes.InsertOnSubmit(userType);
        db.SubmitChanges();
    }

    public int UDF_CheckDuplicate()
    {
        int int_Duplicated = 0;
        LSC_WareHouseDataContext db = new LSC_WareHouseDataContext();
        try
        {
            tblUserType tblUserT = db.tblUserTypes.Single(n => n.UserTypeDescription == Str_UserTypeDescription.Trim());
            if (tblUserT.UserTypeDescription.Trim() == "")
            {
                int_Duplicated = 0;
            }
            else
            {
                int_Duplicated = 1;
            }
        }
        catch
        {
            int_Duplicated = 0;
        }
        return int_Duplicated;
    }

}
