Esempio n. 1
0
        public virtual void Clone(Logindetails sourceObject)
        {
            if (sourceObject == null)
            {
                throw new ArgumentNullException("sourceObject");
            }

            // Clone attributes from source object
            this._ID           = sourceObject.ID;
            this._Name         = sourceObject.Name;
            this._Emailaddress = sourceObject.Emailaddress;
            this._Password     = sourceObject.Password;
            this._createdon    = sourceObject.createdon;
        }
Esempio n. 2
0
        public int Insert(Logindetails logindetails)
        {
            int __rowsAffected = 0;

            // Create command
            using (SqlCommand sqlCommand = new SqlCommand("LogindetailsInsert"))
            {
                // Set command type
                sqlCommand.CommandType = CommandType.StoredProcedure;

                // Add command parameters
                SqlParameter vID = new SqlParameter("@ID", SqlDbType.Int);
                vID.Direction = ParameterDirection.InputOutput;
                sqlCommand.Parameters.Add(vID);
                SqlParameter vName = new SqlParameter("@Name", SqlDbType.NVarChar, 50);
                vName.Direction = ParameterDirection.Input;
                sqlCommand.Parameters.Add(vName);
                SqlParameter vEmailaddress = new SqlParameter("@Emailaddress", SqlDbType.NVarChar, 50);
                vEmailaddress.Direction = ParameterDirection.Input;
                sqlCommand.Parameters.Add(vEmailaddress);
                SqlParameter vPassword = new SqlParameter("@Password", SqlDbType.NVarChar, 50);
                vPassword.Direction = ParameterDirection.Input;
                sqlCommand.Parameters.Add(vPassword);
                SqlParameter vcreatedon = new SqlParameter("@createdon", SqlDbType.DateTime);
                vcreatedon.Direction = ParameterDirection.Input;
                sqlCommand.Parameters.Add(vcreatedon);

                // Set input parameter values
                SqlServerHelper.SetParameterValue(
                    vID,
                    logindetails.ID,
                    0);
                SqlServerHelper.SetParameterValue(vName, logindetails.Name);
                SqlServerHelper.SetParameterValue(vEmailaddress, logindetails.Emailaddress);
                SqlServerHelper.SetParameterValue(vPassword, logindetails.Password);
                SqlServerHelper.SetParameterValue(vcreatedon, logindetails.createdon);

                try
                {
                    // Attach command
                    AttachCommand(sqlCommand);

                    // Execute command
                    __rowsAffected = sqlCommand.ExecuteNonQuery();
                    if (__rowsAffected == 0)
                    {
                        return(__rowsAffected);
                    }


                    // Get output parameter values
                    logindetails.ID = SqlServerHelper.ToInt32(vID);
                }
                finally
                {
                    // Detach command
                    DetachCommand(sqlCommand);
                }
            }

            return(__rowsAffected);
        }