public static UsersTable Get(int Id)
 {
     DBOperations objdb = new DBOperations(Properties.Settings.Default.SuperMarketConnectionString);
     UsersTable objUsersTable = new UsersTable();
     string strGetOneRecord = "SELECT * FROM [Transaction] where Id=@Id";
     string[] strAddParameterName = new string[] { "Id" };
     object[] objAddparametervalue = new object[] { objUsersTable.Id };
     System.Data.DataTable objtab = objdb.ExecuteGetAllQuery(strGetOneRecord, strAddParameterName, objAddparametervalue);
     return objUsersTable;
 }
        public static UsersTable GetByID(UsersTable objUsersTable)
        {
            DBOperations objdb = new DBOperations(Properties.Settings.Default.SuperMarketConnectionString);

            // objUsersTable = new UsersTable();
            string strGetOneRecord = "SELECT * FROM [UsersTable] where Name=@Name";
            string[] strAddParameterName = new string[] { "Name" };
            object[] objAddparametervalue = new object[] { objUsersTable.Name };
            System.Data.DataTable objtab = objdb.ExecuteGetAllQuery(strGetOneRecord, strAddParameterName, objAddparametervalue);
            return objUsersTable;
        }
        public Response Create(UsersTable objUsersTable)
        {
            SQLConnector.DBOperations objdb = new DBOperations(Properties.Settings.Default.SuperMarketConnectionString);
            string stInsert = @"INSERT INTO [UsersTable]([Name] ,[Password])
             VALUES (@Name,@Password)";
            string[] strAddParameterName = new string[] { "Name", "Password"};
            object[] objAddparametervalue = new object[] { objUsersTable.Name, objUsersTable.Password };
            if (!objdb.ExecuteQuery(stInsert, strAddParameterName, objAddparametervalue))
                return new Response(9999, string.Format(Failure_MSG, "insert"));

            else

                return new Response(5555, string.Format(SUCCESS_MSG, "inserted"));
        }
        public static List<UsersTable> GetAll()
        {
            DBOperations objdb = new DBOperations(Properties.Settings.Default.SuperMarketConnectionString);
            List<UsersTable> lstUsersTable = new List<UsersTable>();
            UsersTable objUsersTable = new UsersTable();

            string strGetOneRecord = "SELECT * FROM [UsersTable]";
            string[] strAddParameterName = new string[] { };
            object[] objAddparametervalue = new object[] { };
            DataTable objtab = new DataTable();
            objtab = objdb.ExecuteGetAllQuery(strGetOneRecord, strAddParameterName, objAddparametervalue);

            for (int i = 0; i < objtab.Rows.Count; i++)
            {
                int intId;
                objUsersTable = new UsersTable();
                int.TryParse(objtab.Rows[i]["Id"].ToString(), out intId);
                objUsersTable.Id = intId;
                objUsersTable.Name = objtab.Rows[i]["Name"] != null ? objtab.Rows[i]["Name"].ToString() : string.Empty;
                objUsersTable.Password = objtab.Rows[i]["Password"] != null ? objtab.Rows[i]["Password"].ToString() : string.Empty;
                lstUsersTable.Add(objUsersTable);
            }
            return lstUsersTable;
        }
 public UsersTable GetUserRecord(UsersTable objUsersTable)
 {
     return UsersTable.GetByID(objUsersTable);
 }
        public Response Delete(UsersTable objUsersTable)
        {
            DBOperations objdb = new DBOperations(Properties.Settings.Default.SuperMarketConnectionString);
            string strDelete = "DELETE FROM [UsersTable] WHERE Id=@Id";
            string[] strAddParameterName = new string[] { "Id" };
            object[] objAddparametervalue = new object[] { objUsersTable.Id };
            if (!objdb.ExecuteQuery(strDelete, strAddParameterName, objAddparametervalue))

                return new Response(9999, string.Format(Failure_MSG, "delete"));
            else

                return new Response(5555, string.Format(SUCCESS_MSG, "deleted"));
        }
 public Response Update(UsersTable objUsersTable)
 {
     DBOperations objdb = new DBOperations(Properties.Settings.Default.SuperMarketConnectionString);
     string strUpsate = @"UPDATE [SuperMarket].[dbo].[UsersTable]
     SET [Name] = @Name
     ,[Password] = @Password
      WHERE Id=@Id ";
     string[] strAddParameterName = new string[] { "Name", "Password","Id" };
     object[] objAddparametervalue = new object[] { objUsersTable.Name, objUsersTable.Password, objUsersTable.Id };
     if (!objdb.ExecuteQuery(strUpsate, strAddParameterName, objAddparametervalue))
         return new Response(9999, string.Format(Failure_MSG, "update"));
     else
         return new Response(5555, string.Format(SUCCESS_MSG, "updated"));
 }