예제 #1
0
    public int Insert_tbl_LoginHistory(string Person_Id)
    {
        DataSet ds      = new DataSet();
        int     iResult = 0;

        using (SqlConnection cn = new SqlConnection(ConStr))
        {
            if (cn.State == ConnectionState.Closed)
            {
                cn.Open();
            }
            try
            {
                string sql = "set dateformat dmy; insert into tbl_LoginHistory (LoginHistory_PersonId, LoginHistory_LoggedInTime, LoginHistory_LoggedOutTime, LoginHistory_IPAddress, LoginHistory_MACAddress, LoginHistory_Status) values ('" + Person_Id + "', getdate(), null, '" + AllClasses.getIPAddress() + ", " + AllClasses.getIPAddress2() + "', '" + AllClasses.getMACAddress() + "', 1); select @@IDENTITY";
                ds = ExecuteSelectQuery(sql);
                if (AllClasses.CheckDataSet(ds))
                {
                    iResult = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString());
                }
                else
                {
                    iResult = 0;
                }
            }
            catch (Exception)
            {
                cn.Close();
                iResult = -1;
            }
        }
        return(iResult);
    }